forked from OSchip/llvm-project
[InstCombine] add tests for lshr with mul; NFC
This commit is contained in:
parent
81987396ac
commit
6bcc1fd461
|
@ -259,3 +259,62 @@ define <2 x i32> @narrow_lshr_constant(<2 x i8> %x, <2 x i8> %y) {
|
|||
%sh = lshr <2 x i32> %zx, <i32 3, i32 3>
|
||||
ret <2 x i32> %sh
|
||||
}
|
||||
|
||||
define i32 @mul_splat_fold(i32 %x) {
|
||||
; CHECK-LABEL: @mul_splat_fold(
|
||||
; CHECK-NEXT: [[M:%.*]] = mul nuw i32 [[X:%.*]], 65537
|
||||
; CHECK-NEXT: [[T:%.*]] = lshr i32 [[M]], 16
|
||||
; CHECK-NEXT: ret i32 [[T]]
|
||||
;
|
||||
%m = mul nuw i32 %x, 65537
|
||||
%t = lshr i32 %m, 16
|
||||
ret i32 %t
|
||||
}
|
||||
|
||||
declare void @usevec(<3 x i14>)
|
||||
|
||||
define <3 x i14> @mul_splat_fold_vec(<3 x i14> %x) {
|
||||
; CHECK-LABEL: @mul_splat_fold_vec(
|
||||
; CHECK-NEXT: [[M:%.*]] = mul nuw <3 x i14> [[X:%.*]], <i14 129, i14 129, i14 129>
|
||||
; CHECK-NEXT: call void @usevec(<3 x i14> [[M]])
|
||||
; CHECK-NEXT: [[T:%.*]] = lshr <3 x i14> [[M]], <i14 7, i14 7, i14 7>
|
||||
; CHECK-NEXT: ret <3 x i14> [[T]]
|
||||
;
|
||||
%m = mul nuw <3 x i14> %x, <i14 129, i14 129, i14 129>
|
||||
call void @usevec(<3 x i14> %m)
|
||||
%t = lshr <3 x i14> %m, <i14 7, i14 7, i14 7>
|
||||
ret <3 x i14> %t
|
||||
}
|
||||
|
||||
define i32 @mul_splat_fold_wrong_mul_const(i32 %x) {
|
||||
; CHECK-LABEL: @mul_splat_fold_wrong_mul_const(
|
||||
; CHECK-NEXT: [[M:%.*]] = mul nuw i32 [[X:%.*]], 65538
|
||||
; CHECK-NEXT: [[T:%.*]] = lshr i32 [[M]], 16
|
||||
; CHECK-NEXT: ret i32 [[T]]
|
||||
;
|
||||
%m = mul nuw i32 %x, 65538
|
||||
%t = lshr i32 %m, 16
|
||||
ret i32 %t
|
||||
}
|
||||
|
||||
define i32 @mul_splat_fold_wrong_lshr_const(i32 %x) {
|
||||
; CHECK-LABEL: @mul_splat_fold_wrong_lshr_const(
|
||||
; CHECK-NEXT: [[M:%.*]] = mul nuw i32 [[X:%.*]], 65537
|
||||
; CHECK-NEXT: [[T:%.*]] = lshr i32 [[M]], 15
|
||||
; CHECK-NEXT: ret i32 [[T]]
|
||||
;
|
||||
%m = mul nuw i32 %x, 65537
|
||||
%t = lshr i32 %m, 15
|
||||
ret i32 %t
|
||||
}
|
||||
|
||||
define i32 @mul_splat_fold_no_nuw(i32 %x) {
|
||||
; CHECK-LABEL: @mul_splat_fold_no_nuw(
|
||||
; CHECK-NEXT: [[M:%.*]] = mul nsw i32 [[X:%.*]], 65537
|
||||
; CHECK-NEXT: [[T:%.*]] = lshr i32 [[M]], 16
|
||||
; CHECK-NEXT: ret i32 [[T]]
|
||||
;
|
||||
%m = mul nsw i32 %x, 65537
|
||||
%t = lshr i32 %m, 16
|
||||
ret i32 %t
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue