blob: 2f1c24878de0a91bcddd82b72a26b6f488ef3010 [file] [log] [blame]
Roman Lebedev739c7a02020-07-03 01:53:13 +03001; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
Roman Lebedeve98030a52020-07-03 02:37:29 +03002; RUN: opt %s -scalarizer -scalarize-load-store -dce -S | FileCheck --check-prefixes=ALL %s
Roman Lebedev739c7a02020-07-03 01:53:13 +03003
4target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
5
6; Test that variable extracts scalarized.
7define i32 @f1(<4 x i32> %src, i32 %index) {
8; ALL-LABEL: @f1(
9; ALL-NEXT: [[RES:%.*]] = extractelement <4 x i32> [[SRC:%.*]], i32 [[INDEX:%.*]]
10; ALL-NEXT: ret i32 [[RES]]
11;
12 %res = extractelement <4 x i32> %src, i32 %index
13 ret i32 %res
14}
15
16define i32 @f2(<4 x i32> *%src, i32 %index) {
17; ALL-LABEL: @f2(
Roman Lebedeve98030a52020-07-03 02:37:29 +030018; ALL-NEXT: [[SRC_I0:%.*]] = bitcast <4 x i32>* [[SRC:%.*]] to i32*
19; ALL-NEXT: [[VAL0_I0:%.*]] = load i32, i32* [[SRC_I0]], align 16
20; ALL-NEXT: [[SRC_I1:%.*]] = getelementptr i32, i32* [[SRC_I0]], i32 1
21; ALL-NEXT: [[VAL0_I1:%.*]] = load i32, i32* [[SRC_I1]], align 4
22; ALL-NEXT: [[SRC_I2:%.*]] = getelementptr i32, i32* [[SRC_I0]], i32 2
23; ALL-NEXT: [[VAL0_I2:%.*]] = load i32, i32* [[SRC_I2]], align 8
24; ALL-NEXT: [[SRC_I3:%.*]] = getelementptr i32, i32* [[SRC_I0]], i32 3
25; ALL-NEXT: [[VAL0_I3:%.*]] = load i32, i32* [[SRC_I3]], align 4
Roman Lebedev739c7a02020-07-03 01:53:13 +030026; ALL-NEXT: [[VAL1_I0:%.*]] = shl i32 1, [[VAL0_I0]]
Roman Lebedev739c7a02020-07-03 01:53:13 +030027; ALL-NEXT: [[VAL1_I1:%.*]] = shl i32 2, [[VAL0_I1]]
Roman Lebedev739c7a02020-07-03 01:53:13 +030028; ALL-NEXT: [[VAL1_I2:%.*]] = shl i32 3, [[VAL0_I2]]
Roman Lebedev739c7a02020-07-03 01:53:13 +030029; ALL-NEXT: [[VAL1_I3:%.*]] = shl i32 4, [[VAL0_I3]]
30; ALL-NEXT: [[VAL1_UPTO0:%.*]] = insertelement <4 x i32> undef, i32 [[VAL1_I0]], i32 0
31; ALL-NEXT: [[VAL1_UPTO1:%.*]] = insertelement <4 x i32> [[VAL1_UPTO0]], i32 [[VAL1_I1]], i32 1
32; ALL-NEXT: [[VAL1_UPTO2:%.*]] = insertelement <4 x i32> [[VAL1_UPTO1]], i32 [[VAL1_I2]], i32 2
33; ALL-NEXT: [[VAL1:%.*]] = insertelement <4 x i32> [[VAL1_UPTO2]], i32 [[VAL1_I3]], i32 3
34; ALL-NEXT: [[VAL2:%.*]] = extractelement <4 x i32> [[VAL1]], i32 [[INDEX:%.*]]
35; ALL-NEXT: ret i32 [[VAL2]]
36;
37 %val0 = load <4 x i32> , <4 x i32> *%src
38 %val1 = shl <4 x i32> <i32 1, i32 2, i32 3, i32 4>, %val0
39 %val2 = extractelement <4 x i32> %val1, i32 %index
40 ret i32 %val2
41}