Skip to content

Commit 377da51

Browse files
committed
[InstCombine] Add test for detecting (x ^ -x) as a ~Mask; NFC
1 parent a843f26 commit 377da51

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

llvm/test/Transforms/InstCombine/icmp-and-lowbit-mask.ll

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,25 @@ define i1 @src_is_notmask_shl(i8 %x_in, i8 %y, i1 %cond) {
453453
ret i1 %r
454454
}
455455

456+
define i1 @src_is_notmask_x_xor_neg_x(i8 %x_in, i8 %y, i1 %cond) {
457+
; CHECK-LABEL: @src_is_notmask_x_xor_neg_x(
458+
; CHECK-NEXT: [[X:%.*]] = xor i8 [[X_IN:%.*]], 123
459+
; CHECK-NEXT: [[NEG_Y:%.*]] = sub i8 0, [[Y:%.*]]
460+
; CHECK-NEXT: [[NOTMASK0:%.*]] = xor i8 [[NEG_Y]], [[Y]]
461+
; CHECK-NEXT: [[NOTMASK:%.*]] = select i1 [[COND:%.*]], i8 [[NOTMASK0]], i8 -8
462+
; CHECK-NEXT: [[AND:%.*]] = and i8 [[X]], [[NOTMASK]]
463+
; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[AND]], 0
464+
; CHECK-NEXT: ret i1 [[R]]
465+
;
466+
%x = xor i8 %x_in, 123
467+
%neg_y = sub i8 0, %y
468+
%nmask0 = xor i8 %y, %neg_y
469+
%notmask = select i1 %cond, i8 %nmask0, i8 -8
470+
%and = and i8 %x, %notmask
471+
%r = icmp eq i8 %and, 0
472+
ret i1 %r
473+
}
474+
456475
define i1 @src_is_notmask_shl_fail_multiuse_invert(i8 %x_in, i8 %y, i1 %cond) {
457476
; CHECK-LABEL: @src_is_notmask_shl_fail_multiuse_invert(
458477
; CHECK-NEXT: [[X:%.*]] = xor i8 [[X_IN:%.*]], 122

0 commit comments

Comments
 (0)