diff --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp --- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -4233,8 +4233,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; diff --git a/llvm/test/CodeGen/PowerPC/ppc64-P9-setb.ll b/llvm/test/CodeGen/PowerPC/ppc64-P9-setb.ll --- a/llvm/test/CodeGen/PowerPC/ppc64-P9-setb.ll +++ b/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: {{\}} +; 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 +}