Comment by dmitrygr

1 day ago

> many, if not the vast majority, of aarch64 TBZ/TBNZ are probably branching on a boolean

None are. There is CBZ/CBNZ for that. https://www.scs.stanford.edu/~zyedidia/arm64/cbnz.html

It is just THAT useful to branch in a bit.

Both clang and gcc do actually generate TBZ/TBNZ for checking a bool: https://godbolt.org/z/K6evhaxGT

  • Some stats on an aarch64 binary of my current main project (1.6MB .text, 6600 symbols as per whatever "nm the-binary | wc -l" includes, from "objdump -d the-binary"):

        19546 /tbn?z/
        18029 /tbn?z.*, #0x0/  (but this includes boolean checks)
          224 /tbn?z.*, #0x1f/ (i.e. 32-bit x<0)
         1139 /tbn?z.*, #0x3f/ (i.e. 64-bit x<0)
          154 other immediates
    

    Said project doesn't do fixed bitfields much (there are some, but a chunk of those test multiple bits) so unsurprisingly not much. (I could imagine that the kernel has significantly more, but it's an edge-case (though perhaps an important one) of being basically massive amounts of fixed configurable glue)

    • Did a quick grep over object files of a half build defconfig kernel:

          total: 15510
          #0:  3720
          #31: 2247
          #1:  1349
          #21: 1208
          #2:  810
          #3:  524
          #8:  493
          ...

      1 reply →