You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prior, the code for `intrinsics::cttz` (e.g. `u128.trailing_zeros()`)
was being inlined into the call site, but that code was referencing a
lookup table from the `.rodata` section (placed in flash):
```
40380xxx: 3c0066b7 lui a3,0x3c006
40380xxx: ed168293 addi t0,a3,-303 # 3c005ed1 <str.1+0x81>
40380xxx: 03810813 addi a6,sp,56
...
40380xxx: 41e00633 neg a2,t5
40380xxx: 00cf7633 and a2,t5,a2
40380xxx: 03160633 mul a2,a2,a7
40380xxx: 826d srli a2,a2,0x1b
40380xxx: 9616 add a2,a2,t0
40380xxx: 00064603 lbu a2,0(a2)
```
Caution: The `str.1` symbol name there is a red herring: `str.1` has a
length of just 0x21 bytes, there's just seemingly no symbolic name
associated with the jump table and `str.1` happens to be the closest
preceding label.
I can't claim credit for the `ctz32` algorithm here, all I've done is
copy it from Wikipedia and modify the operations to the Rust
equivalents, and then applied it four times to extend it to a `u128`. I
have tested it both for `0b0..010..0` (single bit set) and `0xff...100`
(all non-trailing bits set) for every bit position, which did catch at
least two mistakes in the translation.
0 commit comments