forked from OSchip/llvm-project
[InstCombine] (-NSW x) u< x --> x s< 0 (PR39480)
Name: (-x) u< x --> x s< 0 %neg_x = sub nsw i8 0, %x ; %x must not be INT_MIN %r = icmp ult i8 %neg_x, %x => %r = icmp slt i8 %x, 0 https://rise4fun.com/Alive/zSuf https://bugs.llvm.org/show_bug.cgi?id=39480
This commit is contained in:
parent
0e1241a3c9
commit
132be1f502
|
@ -3758,6 +3758,11 @@ Instruction *foldICmpXNegX(ICmpInst &I) {
|
|||
NewRHS = Constant::getNullValue(X->getType());
|
||||
break;
|
||||
|
||||
case ICmpInst::ICMP_ULT:
|
||||
NewPred = ICmpInst::ICMP_SLT;
|
||||
NewRHS = Constant::getNullValue(X->getType());
|
||||
break;
|
||||
|
||||
case ICmpInst::ICMP_EQ:
|
||||
case ICmpInst::ICMP_NE:
|
||||
NewPred = Pred;
|
||||
|
|
|
@ -91,8 +91,7 @@ define i1 @t5(i8 %x) {
|
|||
|
||||
define i1 @t6(i8 %x) {
|
||||
; CHECK-LABEL: @t6(
|
||||
; CHECK-NEXT: [[NEG_X:%.*]] = sub nsw i8 0, [[X:%.*]]
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[NEG_X]], [[X]]
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 0
|
||||
; CHECK-NEXT: ret i1 [[CMP]]
|
||||
;
|
||||
%neg_x = sub nsw i8 0, %x
|
||||
|
|
Loading…
Reference in New Issue