Skip to content

Commit 600cad2

Browse files
committed
[InstCombine] Pre-commit tests (NFC)
1 parent ee36dd2 commit 600cad2

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

llvm/test/Transforms/InstCombine/ashr-lshr.ll

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,3 +604,51 @@ define <2 x i8> @ashr_known_pos_exact_vec(<2 x i8> %x, <2 x i8> %y) {
604604
%r = ashr exact <2 x i8> %p, %y
605605
ret <2 x i8> %r
606606
}
607+
608+
define i32 @lshr_mul_times_3_div_2(i32 %0) {
609+
; CHECK-LABEL: @lshr_mul_times_3_div_2(
610+
; CHECK-NEXT: [[MUL:%.*]] = mul nuw nsw i32 [[TMP0:%.*]], 3
611+
; CHECK-NEXT: [[LSHR:%.*]] = lshr i32 [[MUL]], 1
612+
; CHECK-NEXT: ret i32 [[LSHR]]
613+
;
614+
%mul = mul nsw nuw i32 %0, 3
615+
%lshr = lshr i32 %mul, 1
616+
ret i32 %lshr
617+
}
618+
619+
define i32 @lshr_mul_times_3_div_2_exact(i32 %x) {
620+
; CHECK-LABEL: @lshr_mul_times_3_div_2_exact(
621+
; CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 [[X:%.*]], 3
622+
; CHECK-NEXT: [[LSHR:%.*]] = lshr exact i32 [[MUL]], 1
623+
; CHECK-NEXT: ret i32 [[LSHR]]
624+
;
625+
%mul = mul nsw i32 %x, 3
626+
%lshr = lshr exact i32 %mul, 1
627+
ret i32 %lshr
628+
}
629+
630+
define i32 @mul_times_3_div_2_multiuse_lshr(i32 %x) {
631+
; CHECK-LABEL: @mul_times_3_div_2_multiuse_lshr(
632+
; CHECK-NEXT: [[MUL:%.*]] = mul nuw i32 [[X:%.*]], 3
633+
; CHECK-NEXT: [[RES:%.*]] = lshr i32 [[MUL]], 1
634+
; CHECK-NEXT: call void @use(i32 [[MUL]])
635+
; CHECK-NEXT: ret i32 [[RES]]
636+
;
637+
%mul = mul nuw i32 %x, 3
638+
%res = lshr i32 %mul, 1
639+
call void @use (i32 %mul)
640+
ret i32 %res
641+
}
642+
643+
define i32 @lshr_mul_times_3_div_2_exact_2(i32 %x) {
644+
; CHECK-LABEL: @lshr_mul_times_3_div_2_exact_2(
645+
; CHECK-NEXT: [[MUL:%.*]] = mul nuw i32 [[X:%.*]], 3
646+
; CHECK-NEXT: [[LSHR:%.*]] = lshr exact i32 [[MUL]], 1
647+
; CHECK-NEXT: ret i32 [[LSHR]]
648+
;
649+
%mul = mul nuw i32 %x, 3
650+
%lshr = lshr exact i32 %mul, 1
651+
ret i32 %lshr
652+
}
653+
654+
declare void @use(i32)

0 commit comments

Comments
 (0)