Skip to content

Commit 433b878

Browse files
committed
[InstComb] Pre-commit ashr-xor test
1 parent 2108c62 commit 433b878

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

llvm/test/Transforms/InstCombine/shift-logic.ll

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ define i32 @ashr_xor(i32 %x, i32 %py) {
186186
ret i32 %sh1
187187
}
188188

189+
189190
define i32 @shr_mismatch_xor(i32 %x, i32 %y) {
190191
; CHECK-LABEL: @shr_mismatch_xor(
191192
; CHECK-NEXT: [[SH0:%.*]] = ashr i32 [[X:%.*]], 5
@@ -225,6 +226,41 @@ define <2 x i32> @ashr_poison_poison_xor(<2 x i32> %x, <2 x i32> %y) {
225226
ret <2 x i32> %sh1
226227
}
227228

229+
define i32 @ashr_xor_operand_match(i32 %x, i32 %y) {
230+
; CHECK-LABEL: @ashr_xor_operand_match(
231+
; CHECK-NEXT: [[SH1:%.*]] = xor i32 [[TMP1:%.*]], [[TMP2:%.*]]
232+
; CHECK-NEXT: [[RET:%.*]] = ashr i32 [[SH1]], [[TMP1]]
233+
; CHECK-NEXT: ret i32 [[RET]]
234+
;
235+
%r = xor i32 %x, %y
236+
%ret = ashr i32 %r, %x
237+
ret i32 %ret
238+
}
239+
240+
define i32 @ashr_xor_operand_match_multiuse(i32 %x, i32 %y) {
241+
; CHECK-LABEL: @ashr_xor_operand_match_multiuse(
242+
; CHECK-NEXT: [[R:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
243+
; CHECK-NEXT: [[Q:%.*]] = ashr i32 [[R]], [[X]]
244+
; CHECK-NEXT: [[RET:%.*]] = xor i32 [[R]], [[Q]]
245+
; CHECK-NEXT: ret i32 [[RET]]
246+
;
247+
%r = xor i32 %x, %y
248+
%q = ashr i32 %r, %x
249+
%ret = xor i32 %r, %q
250+
ret i32 %ret
251+
}
252+
253+
define i32 @ashr_xor_operand_mismtach(i32 %x, i32 %y) {
254+
; CHECK-LABEL: @ashr_xor_operand_mismtach(
255+
; CHECK-NEXT: [[R:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
256+
; CHECK-NEXT: [[RET:%.*]] = ashr i32 [[R]], [[Y]]
257+
; CHECK-NEXT: ret i32 [[RET]]
258+
;
259+
%r = xor i32 %x, %y
260+
%ret = ashr i32 %r, %y
261+
ret i32 %ret
262+
}
263+
228264
define i32 @lshr_or_extra_use(i32 %x, i32 %y, ptr %p) {
229265
; CHECK-LABEL: @lshr_or_extra_use(
230266
; CHECK-NEXT: [[SH0:%.*]] = lshr i32 [[X:%.*]], 5

0 commit comments

Comments
 (0)