Skip to content

Commit 672df0f

Browse files
committed
[InstSimplify] add tests for expandCommutativeBinOp; NFC
1 parent 99166fd commit 672df0f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt < %s -instsimplify -S | FileCheck %s
3+
4+
; %result = x & (1 ^ sel) = (x & 1) ^ (x & sel)
5+
; = x ^ (select cond, false, false)
6+
; = x ^ false = x
7+
;
8+
define i1 @f(i1 %cond, i1 noundef %x, i1 %y, i1 %z) {
9+
; CHECK-LABEL: @f(
10+
; CHECK-NEXT: ret i1 [[X:%.*]]
11+
;
12+
%notx = xor i1 %x, 1
13+
%lhs = and i1 %notx, %y
14+
%rhs = and i1 %notx, %z
15+
%sel = select i1 %cond, i1 %lhs, i1 %rhs
16+
%op1 = xor i1 1, %sel
17+
%result = and i1 %x, %op1
18+
ret i1 %result
19+
}
20+
21+
define i1 @f_dontfold(i1 %cond, i1 %x, i1 %y, i1 %z) {
22+
; CHECK-LABEL: @f_dontfold(
23+
; CHECK-NEXT: ret i1 [[X:%.*]]
24+
;
25+
%notx = xor i1 %x, 1
26+
%lhs = and i1 %notx, %y
27+
%rhs = and i1 %notx, %z
28+
%sel = select i1 %cond, i1 %lhs, i1 %rhs
29+
%op1 = xor i1 1, %sel
30+
%result = and i1 %x, %op1
31+
ret i1 %result
32+
}

0 commit comments

Comments
 (0)