Skip to content

Commit 867bb0d

Browse files
committed
[InstCombine] Drop samesign in InstCombinerImpl::foldSelectEqualityTest
1 parent 6b64a2b commit 867bb0d

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,6 +1448,7 @@ Instruction *InstCombinerImpl::foldSelectEqualityTest(SelectInst &Sel) {
14481448
m_c_SpecificICmp(ICmpInst::ICMP_EQ, m_Specific(X), m_Specific(Y))))
14491449
return nullptr;
14501450

1451+
cast<ICmpInst>(XeqY)->setSameSign(false);
14511452
return replaceInstUsesWith(Sel, XeqY);
14521453
}
14531454

llvm/test/Transforms/InstCombine/icmp-equality-test.ll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ entry:
3333
ret i1 %equal
3434
}
3535

36+
define i1 @icmp_equality_test_constant_samesign(i42 %X, i42 %Y) {
37+
; CHECK-LABEL: @icmp_equality_test_constant_samesign(
38+
; CHECK-NEXT: entry:
39+
; CHECK-NEXT: [[XEQY:%.*]] = icmp eq i42 [[X:%.*]], [[Y:%.*]]
40+
; CHECK-NEXT: ret i1 [[XEQY]]
41+
;
42+
entry:
43+
%XeqC = icmp eq i42 %X, -42
44+
%YeqC = icmp eq i42 %Y, -42
45+
%XeqY = icmp samesign eq i42 %X, %Y
46+
%not.YeqC = xor i1 %YeqC, true
47+
%and = select i1 %not.YeqC, i1 %XeqY, i1 false
48+
%equal = select i1 %XeqC, i1 %YeqC, i1 %and
49+
ret i1 %equal
50+
}
51+
3652
define i1 @icmp_equality_test_swift_optional_pointers(i64 %X, i64 %Y) {
3753
; CHECK-LABEL: @icmp_equality_test_swift_optional_pointers(
3854
; CHECK-NEXT: entry:

0 commit comments

Comments
 (0)