Roman Lebedev | 739c7a0 | 2020-07-03 01:53:13 +0300 | [diff] [blame] | 1 | ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
Roman Lebedev | e98030a5 | 2020-07-03 02:37:29 +0300 | [diff] [blame] | 2 | ; RUN: opt %s -scalarizer -scalarize-load-store -dce -S | FileCheck --check-prefixes=ALL %s |
Roman Lebedev | 739c7a0 | 2020-07-03 01:53:13 +0300 | [diff] [blame] | 3 | |
| 4 | target 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. |
| 7 | define 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 | |
| 16 | define i32 @f2(<4 x i32> *%src, i32 %index) { |
| 17 | ; ALL-LABEL: @f2( |
Roman Lebedev | e98030a5 | 2020-07-03 02:37:29 +0300 | [diff] [blame] | 18 | ; 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 Lebedev | 739c7a0 | 2020-07-03 01:53:13 +0300 | [diff] [blame] | 26 | ; ALL-NEXT: [[VAL1_I0:%.*]] = shl i32 1, [[VAL0_I0]] |
Roman Lebedev | 739c7a0 | 2020-07-03 01:53:13 +0300 | [diff] [blame] | 27 | ; ALL-NEXT: [[VAL1_I1:%.*]] = shl i32 2, [[VAL0_I1]] |
Roman Lebedev | 739c7a0 | 2020-07-03 01:53:13 +0300 | [diff] [blame] | 28 | ; ALL-NEXT: [[VAL1_I2:%.*]] = shl i32 3, [[VAL0_I2]] |
Roman Lebedev | 739c7a0 | 2020-07-03 01:53:13 +0300 | [diff] [blame] | 29 | ; 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 | } |