There was an error being thrown from isDesirableToCommuteWithShift in
some tests. This was tracked down to the method being called before
legalisation, with an extended value type, not a machine value type.
In the case I diagnosed, the error was only hit with an instruction sequence
involving i24s in the add and shift. i24 is not a Machine ValueType, it is
instead an Extended ValueType which was causing the issue.
I have added a test to cover this case, and fixed the error in the callback.
Sam, I just noted when building compiler-rt (/compiler-rt/lib/builtins/addtf3.c) in debug mode, it crashes in this line.
The reason is ShiftedC1Int bitwidth is 128, but APInt getSExtValue expects a 64 bit quantity.
Can you take a look?
One solution is:
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -1003,6 +1003,8 @@ bool RISCVTargetLowering::isDesirableToCommuteWithShift(
+ if (ShiftedC1Int.getBitWidth() > 64)
+ return false;
Reduced test case:
define void @test(i128* %a) {
entry:
ret void
}