Skip to content

Commit 04697aa

Browse files
committed
[InstCombine] Add test for displaced shift fold with or disjoint (NFC)
1 parent e825cc4 commit 04697aa

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

llvm/test/Transforms/InstCombine/binop-of-displaced-shifts.ll

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,35 @@ define <2 x i8> @shl_or_non_splat_out_of_range(<2 x i8> %x) {
328328
%binop = or <2 x i8> %shift, %shift2
329329
ret <2 x i8> %binop
330330
}
331+
332+
define i8 @shl_or_with_or_disjoint_instead_of_add(i8 %x) {
333+
; CHECK-LABEL: define i8 @shl_or_with_or_disjoint_instead_of_add
334+
; CHECK-SAME: (i8 [[X:%.*]]) {
335+
; CHECK-NEXT: [[SHIFT:%.*]] = shl i8 16, [[X]]
336+
; CHECK-NEXT: [[ADD:%.*]] = or disjoint i8 [[X]], 1
337+
; CHECK-NEXT: [[SHIFT2:%.*]] = shl i8 3, [[ADD]]
338+
; CHECK-NEXT: [[BINOP:%.*]] = or i8 [[SHIFT]], [[SHIFT2]]
339+
; CHECK-NEXT: ret i8 [[BINOP]]
340+
;
341+
%shift = shl i8 16, %x
342+
%add = or disjoint i8 %x, 1
343+
%shift2 = shl i8 3, %add
344+
%binop = or i8 %shift, %shift2
345+
ret i8 %binop
346+
}
347+
348+
define i8 @shl_or_with_or_instead_of_add(i8 %x) {
349+
; CHECK-LABEL: define i8 @shl_or_with_or_instead_of_add
350+
; CHECK-SAME: (i8 [[X:%.*]]) {
351+
; CHECK-NEXT: [[SHIFT:%.*]] = shl i8 16, [[X]]
352+
; CHECK-NEXT: [[ADD:%.*]] = or i8 [[X]], 1
353+
; CHECK-NEXT: [[SHIFT2:%.*]] = shl i8 3, [[ADD]]
354+
; CHECK-NEXT: [[BINOP:%.*]] = or i8 [[SHIFT]], [[SHIFT2]]
355+
; CHECK-NEXT: ret i8 [[BINOP]]
356+
;
357+
%shift = shl i8 16, %x
358+
%add = or i8 %x, 1
359+
%shift2 = shl i8 3, %add
360+
%binop = or i8 %shift, %shift2
361+
ret i8 %binop
362+
}

0 commit comments

Comments
 (0)