Skip to content

Commit b073e87

Browse files
committed
[DAGCombine] Correctly extend the constant RHS
1 parent 372b28b commit b073e87

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5125,10 +5125,11 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1,
51255125
!ISD::isUnsignedIntSetCC(Cond))) &&
51265126
isTypeDesirableForOp(ISD::SETCC, N0.getOperand(0).getValueType())) {
51275127
EVT NewVT = N0.getOperand(0).getValueType();
5128-
SDValue NewConst = DAG.getConstant(ISD::isSignedIntSetCC(Cond)
5129-
? C1.sext(NewVT.getSizeInBits())
5130-
: C1.zext(NewVT.getSizeInBits()),
5131-
dl, NewVT);
5128+
SDValue NewConst = DAG.getConstant(
5129+
(N0->getFlags().hasNoSignedWrap() && !ISD::isUnsignedIntSetCC(Cond))
5130+
? C1.sext(NewVT.getSizeInBits())
5131+
: C1.zext(NewVT.getSizeInBits()),
5132+
dl, NewVT);
51325133
return DAG.getSetCC(dl, VT, N0.getOperand(0), NewConst, Cond);
51335134
}
51345135

llvm/test/CodeGen/X86/pr152630.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ define i32 @pr152630(i1 %cond) nounwind {
66
; CHECK: # %bb.0: # %entry
77
; CHECK-NEXT: andl $1, %edi
88
; CHECK-NEXT: decl %edi
9-
; CHECK-NEXT: cmpl $255, %edi
9+
; CHECK-NEXT: cmpl $-1, %edi
1010
; CHECK-NEXT: je .LBB0_2
1111
; CHECK-NEXT: # %bb.1: # %entry
1212
; CHECK-NEXT: movzbl %dil, %eax

0 commit comments

Comments
 (0)