[PATCH] D64425: [RISCV] Fix ICE in isDesirableToCommuteWithShift
Sam Elliott via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 9 09:17:37 PDT 2019
lenary created this revision.
lenary added reviewers: asb, luismarques.
Herald added subscribers: llvm-commits, Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, MaskRay, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, apazos, simoncook, johnrusso, rbar, hiraditya.
Herald added a project: LLVM.
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 `i24`s 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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D64425
Files:
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/add-before-shl.ll
Index: llvm/test/CodeGen/RISCV/add-before-shl.ll
===================================================================
--- llvm/test/CodeGen/RISCV/add-before-shl.ll
+++ llvm/test/CodeGen/RISCV/add-before-shl.ll
@@ -72,3 +72,22 @@
%3 = ashr i32 %2, 16
ret i32 %3
}
+
+define signext i24 @add_non_machine_type(i24 signext %a) nounwind {
+; RV32I-LABEL: add_non_machine_type:
+; RV32I: # %bb.0:
+; RV32I-NEXT: addi a0, a0, 256
+; RV32I-NEXT: slli a0, a0, 20
+; RV32I-NEXT: srai a0, a0, 8
+; RV32I-NEXT: ret
+;
+; RV64I-LABEL: add_non_machine_type:
+; RV64I: # %bb.0:
+; RV64I-NEXT: addi a0, a0, 256
+; RV64I-NEXT: slli a0, a0, 52
+; RV64I-NEXT: srai a0, a0, 40
+; RV64I-NEXT: ret
+ %1 = add i24 %a, 256
+ %2 = shl i24 %1, 12
+ ret i24 %2
+}
Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -995,7 +995,7 @@
// (shl (add x, c1), c2) -> (add (shl x, c2), c1 << c2)
// (shl (or x, c1), c2) -> (or (shl x, c2), c1 << c2)
SDValue N0 = N->getOperand(0);
- MVT Ty = N0.getSimpleValueType();
+ EVT Ty = N0.getValueType();
if (Ty.isScalarInteger() &&
(N0.getOpcode() == ISD::ADD || N0.getOpcode() == ISD::OR)) {
auto *C1 = dyn_cast<ConstantSDNode>(N0->getOperand(1));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64425.208713.patch
Type: text/x-patch
Size: 1399 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190709/b18c48cc/attachment.bin>
More information about the llvm-commits
mailing list