Skip to content

Commit a3b88b8

Browse files
committed
[InstSimpify] Add tests for simplify select with X & Y == -1 cond; NFC
1 parent ff24e9a commit a3b88b8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

llvm/test/Transforms/InstCombine/select.ll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4837,3 +4837,19 @@ define i32 @replace_and_cond_multiuse2(i1 %cond1, i1 %cond2) {
48374837
%mux = select i1 %cond1, i32 %sel, i32 1
48384838
ret i32 %mux
48394839
}
4840+
4841+
define i32 @src_simplify_2x_at_once_and(i32 %x, i32 %y) {
4842+
; CHECK-LABEL: @src_simplify_2x_at_once_and(
4843+
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], [[Y:%.*]]
4844+
; CHECK-NEXT: [[AND0:%.*]] = icmp eq i32 [[AND]], -1
4845+
; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[X]], [[Y]]
4846+
; CHECK-NEXT: [[COND:%.*]] = select i1 [[AND0]], i32 0, i32 [[XOR]]
4847+
; CHECK-NEXT: ret i32 [[COND]]
4848+
;
4849+
%and = and i32 %x, %y
4850+
%and0 = icmp eq i32 %and, -1
4851+
%sub = sub i32 %x, %y
4852+
%xor = xor i32 %x, %y
4853+
%cond = select i1 %and0, i32 %sub, i32 %xor
4854+
ret i32 %cond
4855+
}

0 commit comments

Comments
 (0)