ISD::ROTL/ROTR rotation values are guaranteed to act as a modulo amount, so for power-of-2 bitwidths we only need the lowest bits.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/test/CodeGen/SystemZ/rot-01.ll | ||
---|---|---|
13 | In order for this test to still test what it is intended to test (see below), this should probably be changed to 16 instead of 32 now. | |
31 | This should be 32. The point of this test is that we actually need the AND, but we should use the most efficient instruction (when using the result of the AND only in a rotate, we can implement the AND via NILL instead of the NILF we'd otherwise require). | |
llvm/test/CodeGen/SystemZ/rot-02.ll | ||
7 | With these changes, only 5 bits count (instead of 6 bits) when operating on 32-bit variables. You should probably change the comment here to 5 bits, and then change the AND constant from 31 to 15 or so. | |
llvm/test/CodeGen/SystemZ/shift-04.ll | ||
100–101 | Now that we actually do mask the amount, the comment should be updated. | |
120 | Now I'm wondering: why doesn't the masking also work here? | |
150 | Or here? | |
160 | Likewise. | |
llvm/test/CodeGen/SystemZ/shift-08.ll | ||
101–102 | Same comments as with shift-04.ll apply to this file. |
See my inline comment. I only checked rol8 on AVR but I think the same applies to ror8. Basically it seems like the transformation is correct but will make the operation unacceptably slower.
I'm not sure I can help you fix this, I'm still very new to backend development.
llvm/test/CodeGen/AVR/rot.ll | ||
---|---|---|
7 ↗ | (On Diff #250518) | If I'm reading this IR, correctly, it does a rotate left just as the name implies. // r24 = val // r22 = amt def rol8(r24, r22): r22 &= 7 // this mask is removed by this patch if r22 == 0: return r24 // return value (LBB0_2) while 1: r24 = (r24 << 1) | (r24 >> 7) // rotate r24 left by 1 (lsl, adc) r22 -= 1 if r22 == 0: // brne .LBB0_1 return r24 // .LBB0_2, ret So if you're calling rol8(x, 200) it will take 200 iterations to rotate a number. |
llvm/test/CodeGen/AVR/rot.ll | ||
---|---|---|
7 ↗ | (On Diff #250518) | I think this is a fault in the AVR backend - ROTL/ROTR/FSHL/FSHR all assume modulo amounts, so AVRTargetLowering::LowerShifts should mask accordingly. I'll add this to the patch shortly. |
In order for this test to still test what it is intended to test (see below), this should probably be changed to 16 instead of 32 now.