Skip to content

Commit 05d929e

Browse files
committed
[InstCombine] Drop samesign flags in foldLogOpOfMaskedICmps_NotAllZeros_BMask_Mixed
1 parent 0ce089b commit 05d929e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,11 @@ static Value *foldLogOpOfMaskedICmps_NotAllZeros_BMask_Mixed(
455455
// RHS. For example,
456456
// (icmp ne (A & 255), 0) & (icmp eq (A & 15), 8) -> (icmp eq (A & 15), 8).
457457
// (icmp ne (A & 15), 0) & (icmp eq (A & 15), 8) -> (icmp eq (A & 15), 8).
458-
if (IsSuperSetOrEqual(BCst, DCst))
458+
if (IsSuperSetOrEqual(BCst, DCst)) {
459+
// We can't guarantee that samesign hold after this fold.
460+
RHS->setSameSign(false);
459461
return RHS;
462+
}
460463
// Otherwise, B is a subset of D. If B and E have a common bit set,
461464
// ie. (B & E) != 0, then LHS is subsumed by RHS. For example.
462465
// (icmp ne (A & 12), 0) & (icmp eq (A & 15), 8) -> (icmp eq (A & 15), 8).

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1903,7 +1903,7 @@ define i1 @masked_icmps_bmask_notmixed_not_subset_notoptimized(i32 %A) {
19031903

19041904
define i1 @pr120361(i8 %x, i8 %y) {
19051905
; CHECK-LABEL: @pr120361(
1906-
; CHECK-NEXT: [[CMP1:%.*]] = icmp samesign eq i8 [[X:%.*]], -1
1906+
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[X:%.*]], -1
19071907
; CHECK-NEXT: ret i1 [[CMP1]]
19081908
;
19091909
%cmp1 = icmp samesign eq i8 %x, -1

0 commit comments

Comments
 (0)