xref: /llvm-project/llvm/test/Transforms/SLPVectorizer/RISCV/trunc-bv-multi-uses.ll (revision 38fffa630ee80163dc65e759392ad29798905679)
14c28494eSAlexey Bataev; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
24c28494eSAlexey Bataev; RUN: opt -S --passes=slp-vectorizer -mtriple=riscv64-unknown-linux-gnu -mattr="+v" < %s -slp-threshold=-10 | FileCheck %s
34c28494eSAlexey Bataev
44c28494eSAlexey Bataevdefine i32 @test(i64 %v1, i64 %v2) {
54c28494eSAlexey Bataev; CHECK-LABEL: define i32 @test(
64c28494eSAlexey Bataev; CHECK-SAME: i64 [[V1:%.*]], i64 [[V2:%.*]]) #[[ATTR0:[0-9]+]] {
74c28494eSAlexey Bataev; CHECK-NEXT:  entry:
84c28494eSAlexey Bataev; CHECK-NEXT:    [[TMP0:%.*]] = insertelement <2 x i64> poison, i64 [[V1]], i32 0
94c28494eSAlexey Bataev; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <2 x i64> [[TMP0]], i64 [[V2]], i32 1
104c28494eSAlexey Bataev; CHECK-NEXT:    [[TMP2:%.*]] = trunc <2 x i64> [[TMP1]] to <2 x i32>
11*38fffa63SPaul Walker; CHECK-NEXT:    [[TMP4:%.*]] = lshr <2 x i64> [[TMP1]], splat (i64 32)
124c28494eSAlexey Bataev; CHECK-NEXT:    [[TMP5:%.*]] = trunc <2 x i64> [[TMP4]] to <2 x i32>
134c28494eSAlexey Bataev; CHECK-NEXT:    [[TMP6:%.*]] = add <2 x i32> [[TMP2]], [[TMP5]]
144c28494eSAlexey Bataev; CHECK-NEXT:    [[TMP7:%.*]] = extractelement <2 x i32> [[TMP6]], i32 0
154c28494eSAlexey Bataev; CHECK-NEXT:    [[TMP8:%.*]] = extractelement <2 x i32> [[TMP6]], i32 1
164c28494eSAlexey Bataev; CHECK-NEXT:    [[MUL:%.*]] = mul i32 [[TMP7]], [[TMP8]]
174c28494eSAlexey Bataev; CHECK-NEXT:    ret i32 [[MUL]]
184c28494eSAlexey Bataev;
194c28494eSAlexey Bataeventry:
204c28494eSAlexey Bataev  %t1 = trunc i64 %v1 to i32
214c28494eSAlexey Bataev  %t2 = trunc i64 %v2 to i32
224c28494eSAlexey Bataev  %lshr1 = lshr i64 %v1, 32
234c28494eSAlexey Bataev  %lshr2 = lshr i64 %v2, 32
244c28494eSAlexey Bataev  %t3 = trunc i64 %lshr1 to i32
254c28494eSAlexey Bataev  %t4 = trunc i64 %lshr2 to i32
264c28494eSAlexey Bataev  %add1 = add i32 %t1, %t3
274c28494eSAlexey Bataev  %add2 = add i32 %t2, %t4
284c28494eSAlexey Bataev  %mul = mul i32 %add1, %add2
294c28494eSAlexey Bataev  ret i32 %mul
304c28494eSAlexey Bataev}
31