[PATCH] D90142: [PowerPC] Fix a crash in POWER 9 setb peephole
Qiu Chaofan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 26 03:18:44 PDT 2020
qiucf created this revision.
qiucf added reviewers: jsji, nemanjai, PowerPC, steven.zhang, jedilyn.
Herald added subscribers: llvm-commits, shchenz, kbarton, hiraditya.
Herald added a project: LLVM.
qiucf requested review of this revision.
Variable `InnerIsSel` references `FalseRes`, while `FalseRes` might be `zext`/`sext`. So `InnerIsSel` should reference `SetOrSelCC`, otherwise a crash will happen.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D90142
Files:
llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
llvm/test/CodeGen/PowerPC/ppc64-P9-setb.ll
Index: llvm/test/CodeGen/PowerPC/ppc64-P9-setb.ll
===================================================================
--- llvm/test/CodeGen/PowerPC/ppc64-P9-setb.ll
+++ llvm/test/CodeGen/PowerPC/ppc64-P9-setb.ll
@@ -1328,3 +1328,18 @@
; CHECK: isel
; CHECK: blr
}
+
+; Verify this case doesn't crash
+define void @setbn4(i128 %0, i32* %sel.out) {
+entry:
+; CHECK-LABEL: setbn4:
+; CHECK-NOT: {{\<setb\>}}
+; CHECK: isel
+; CHECK: blr
+ %c1 = icmp ult i128 %0, 5192296858534827628530496329220096
+ %c2 = icmp ugt i128 %0, 5192296858534827628530496329220096
+ %ext = zext i1 %c2 to i32
+ %sel = select i1 %c1, i32 -1, i32 %ext
+ store i32 %sel, i32* %sel.out, align 4
+ ret void
+}
Index: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
+++ llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
@@ -4227,8 +4227,10 @@
(FalseRes.getOpcode() != ISD::SELECT_CC || CC != ISD::SETEQ)))
return false;
- bool InnerIsSel = FalseRes.getOpcode() == ISD::SELECT_CC;
- SDValue SetOrSelCC = InnerIsSel ? FalseRes : FalseRes.getOperand(0);
+ SDValue SetOrSelCC = FalseRes.getOpcode() == ISD::SELECT_CC
+ ? FalseRes
+ : FalseRes.getOperand(0);
+ bool InnerIsSel = SetOrSelCC.getOpcode() == ISD::SELECT_CC;
if (SetOrSelCC.getOpcode() != ISD::SETCC &&
SetOrSelCC.getOpcode() != ISD::SELECT_CC)
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90142.300614.patch
Type: text/x-patch
Size: 1487 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201026/2b361fa2/attachment.bin>
More information about the llvm-commits
mailing list