forked from OSchip/llvm-project
[InstCombine] add tests for shl-of-sub; NFC
This commit is contained in:
parent
06e2a0684e
commit
b75ed244af
|
@ -1,6 +1,8 @@
|
|||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt -instcombine -S < %s | FileCheck %s
|
||||
|
||||
declare void @use(i32)
|
||||
|
||||
define i32 @shl_sub_i32(i32 %x) {
|
||||
; CHECK-LABEL: @shl_sub_i32(
|
||||
; CHECK-NEXT: [[R:%.*]] = lshr i32 -2147483648, [[X:%.*]]
|
||||
|
@ -176,5 +178,37 @@ define <3 x i64> @shl_sub_i64_vec_undef_bad2(<3 x i64> %x) {
|
|||
ret <3 x i64> %r
|
||||
}
|
||||
|
||||
define i32 @shl_const_op1_sub_const_op0(i32 %x) {
|
||||
; CHECK-LABEL: @shl_const_op1_sub_const_op0(
|
||||
; CHECK-NEXT: [[S_NEG:%.*]] = mul i32 [[X:%.*]], -8
|
||||
; CHECK-NEXT: [[R:%.*]] = add i32 [[S_NEG]], 336
|
||||
; CHECK-NEXT: ret i32 [[R]]
|
||||
;
|
||||
%s = sub i32 42, %x
|
||||
%r = shl i32 %s, 3
|
||||
ret i32 %r
|
||||
}
|
||||
|
||||
declare void @use(i32)
|
||||
define <2 x i32> @shl_const_op1_sub_const_op0_splat(<2 x i32> %x) {
|
||||
; CHECK-LABEL: @shl_const_op1_sub_const_op0_splat(
|
||||
; CHECK-NEXT: [[S_NEG:%.*]] = mul <2 x i32> [[X:%.*]], <i32 -8, i32 -8>
|
||||
; CHECK-NEXT: [[R:%.*]] = add <2 x i32> [[S_NEG]], <i32 336, i32 336>
|
||||
; CHECK-NEXT: ret <2 x i32> [[R]]
|
||||
;
|
||||
%s = sub <2 x i32> <i32 42, i32 42>, %x
|
||||
%r = shl <2 x i32> %s, <i32 3, i32 3>
|
||||
ret <2 x i32> %r
|
||||
}
|
||||
|
||||
define i32 @shl_const_op1_sub_const_op0_use(i32 %x) {
|
||||
; CHECK-LABEL: @shl_const_op1_sub_const_op0_use(
|
||||
; CHECK-NEXT: [[S:%.*]] = sub i32 42, [[X:%.*]]
|
||||
; CHECK-NEXT: call void @use(i32 [[S]])
|
||||
; CHECK-NEXT: [[R:%.*]] = shl i32 [[S]], 3
|
||||
; CHECK-NEXT: ret i32 [[R]]
|
||||
;
|
||||
%s = sub i32 42, %x
|
||||
call void @use(i32 %s)
|
||||
%r = shl i32 %s, 3
|
||||
ret i32 %r
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue