You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[InstSimplify] Simplify to vector constants when possible
InstSimplify should do all transformations that ConstProp does, but
one thing that ConstProp does that InstSimplify wouldn't is inline
vector instructions that are constants, e.g. into a ret.
Previously vector instructions wouldn't be inlined in InstSimplify
because llvm::Simplify*Instruction() would return nullptr for specific
instructions, such as vector instructions that were actually constants,
if it couldn't simplify them.
This changes SimplifyInsertElementInst, SimplifyExtractElementInst, and
SimplifyShuffleVectorInst to return a vector constant when possible.
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D85946
Copy file name to clipboardExpand all lines: llvm/test/Analysis/ConstantFolding/vscale-shufflevector.ll
+1-3Lines changed: 1 addition & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -15,9 +15,7 @@ target triple = "aarch64"
15
15
; the compiler. It happens to be the case that this will be the result.
16
16
17
17
; CHECK-LABEL: define <vscale x 8 x i1> @vscale_version()
18
-
; CHECK-NEXT: %splatter = insertelement <vscale x 8 x i1> undef, i1 true, i32 0
19
-
; CHECK-NEXT: %foo = shufflevector <vscale x 8 x i1> %splatter, <vscale x 8 x i1> undef, <vscale x 8 x i32> zeroinitializer
20
-
; CHECK-NEXT: ret <vscale x 8 x i1> %foo
18
+
; CHECK-NEXT: ret <vscale x 8 x i1> shufflevector (<vscale x 8 x i1> insertelement (<vscale x 8 x i1> undef, i1 true, i32 0), <vscale x 8 x i1> undef, <vscale x 8 x i32> zeroinitializer)
21
19
22
20
define <vscale x 8 x i1> @vscale_version() {
23
21
%splatter = insertelement <vscale x 8 x i1> undef, i1true, i320
; CHECK-NEXT: ret <vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> undef, i32 1, i32 0), <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer)
65
+
;
66
+
%i = insertelement <vscale x 4 x i32> undef, i321, i320
67
+
%i2 = shufflevector <vscale x 4 x i32> %i, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
68
+
ret <vscale x 4 x i32> %i2
69
+
}
70
+
54
71
; extractelement
55
72
56
73
definei32@extractelement_idx_undef(<vscale x 4 x i32> %a) {
@@ -120,6 +137,16 @@ define <vscale x 2 x i1> @cmp_le_smax_always_true(<vscale x 2 x i64> %x) {
120
137
ret <vscale x 2 x i1> %cmp
121
138
}
122
139
140
+
define <vscale x 4 x float> @bitcast() {
141
+
; CHECK-LABEL: @bitcast(
142
+
; CHECK-NEXT: ret <vscale x 4 x float> bitcast (<vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> undef, i32 1, i32 0), <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer) to <vscale x 4 x float>)
143
+
;
144
+
%i1 = insertelement <vscale x 4 x i32> undef, i321, i320
145
+
%i2 = shufflevector <vscale x 4 x i32> %i1, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
146
+
%i3 = bitcast <vscale x 4 x i32> %i2to <vscale x 4 x float>
0 commit comments