Skip to content

Commit aa7d82f

Browse files
committed
[InstCombine] Add pre-commit tests
1 parent 1193f7d commit aa7d82f

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
3+
4+
define i32 @fold_xor_with_disjoint_or(i32 %a, i1 %c) {
5+
; CHECK-LABEL: define i32 @fold_xor_with_disjoint_or(
6+
; CHECK-SAME: i32 [[A:%.*]], i1 [[C:%.*]]) {
7+
; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i32 0, i32 4
8+
; CHECK-NEXT: [[SHL:%.*]] = shl i32 [[A]], 4
9+
; CHECK-NEXT: [[OR:%.*]] = or disjoint i32 [[S]], [[SHL]]
10+
; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[OR]], 4
11+
; CHECK-NEXT: ret i32 [[XOR]]
12+
;
13+
%s = select i1 %c, i32 0, i32 4
14+
%shl = shl i32 %a, 4
15+
%or = or disjoint i32 %s, %shl
16+
%xor = xor i32 %or, 4
17+
ret i32 %xor
18+
}
19+
20+
define <2 x i32> @fold_xor_with_disjoint_or_vec(<2 x i32> %a, i1 %c) {
21+
; CHECK-LABEL: define <2 x i32> @fold_xor_with_disjoint_or_vec(
22+
; CHECK-SAME: <2 x i32> [[A:%.*]], i1 [[C:%.*]]) {
23+
; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], <2 x i32> zeroinitializer, <2 x i32> <i32 4, i32 4>
24+
; CHECK-NEXT: [[SHL:%.*]] = shl <2 x i32> [[A]], <i32 4, i32 4>
25+
; CHECK-NEXT: [[OR:%.*]] = or disjoint <2 x i32> [[S]], [[SHL]]
26+
; CHECK-NEXT: [[XOR:%.*]] = xor <2 x i32> [[OR]], <i32 4, i32 4>
27+
; CHECK-NEXT: ret <2 x i32> [[XOR]]
28+
;
29+
%s = select i1 %c, <2 x i32> <i32 0, i32 0>, <2 x i32> <i32 4, i32 4>
30+
%shl = shl <2 x i32> %a, <i32 4, i32 4>
31+
%or = or disjoint <2 x i32> %s, %shl
32+
%xor = xor <2 x i32> %or, <i32 4, i32 4>
33+
ret <2 x i32> %xor
34+
}

0 commit comments

Comments
 (0)