@@ -72,3 +72,56 @@ define <8 x float> @widen_extract4(<8 x float> %ins, <2 x float> %ext) {
72
72
ret <8 x float > %i1
73
73
}
74
74
75
+ ; PR26015: https://llvm.org/bugs/show_bug.cgi?id=26015
76
+ ; The widening shuffle must be inserted before any uses.
77
+
78
+ define <8 x i16 > @pr26015 (<4 x i16 > %t0 ) {
79
+ ; CHECK-LABEL: @pr26015(
80
+ ; CHECK-NEXT: %[[WIDEVEC:.*]] = shufflevector <4 x i16> %t0, <4 x i16> undef, <8 x i32> <i32 undef, i32 undef, i32 undef, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
81
+ ; CHECK-NEXT: %[[EXT:.*]] = extractelement <4 x i16> %t0, i32 2
82
+ ; CHECK-NEXT: %t2 = insertelement <8 x i16> <i16 0, i16 0, i16 0, i16 undef, i16 0, i16 0, i16 undef, i16 undef>, i16 %[[EXT]], i32 3
83
+ ; CHECK-NEXT: %t3 = insertelement <8 x i16> %t2, i16 0, i32 6
84
+ ; CHECK-NEXT: %t5 = shufflevector <8 x i16> %t3, <8 x i16> %[[WIDEVEC]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 11>
85
+ ; CHECK-NEXT: ret <8 x i16> %t5
86
+ %t1 = extractelement <4 x i16 > %t0 , i32 2
87
+ %t2 = insertelement <8 x i16 > zeroinitializer , i16 %t1 , i32 3
88
+ %t3 = insertelement <8 x i16 > %t2 , i16 0 , i32 6
89
+ %t4 = extractelement <4 x i16 > %t0 , i32 3
90
+ %t5 = insertelement <8 x i16 > %t3 , i16 %t4 , i32 7
91
+ ret <8 x i16 > %t5
92
+ }
93
+
94
+ ; PR25999: https://llvm.org/bugs/show_bug.cgi?id=25999
95
+ ; TODO: The widening shuffle could be inserted at the start of the function to allow the first extract to use it.
96
+
97
+ define <8 x i16 > @pr25999 (<4 x i16 > %t0 , i1 %b ) {
98
+ ; CHECK-LABEL: @pr25999(
99
+ ; CHECK-NEXT: %t1 = extractelement <4 x i16> %t0, i32 2
100
+ ; CHECK-NEXT: br i1 %b, label %if, label %end
101
+ ; CHECK: if:
102
+ ; CHECK-NEXT: %[[WIDEVEC:.*]] = shufflevector <4 x i16> %t0, <4 x i16> undef, <8 x i32> <i32 undef, i32 undef, i32 undef, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
103
+ ; CHECK-NEXT: %t2 = insertelement <8 x i16> <i16 0, i16 0, i16 0, i16 undef, i16 0, i16 0, i16 undef, i16 undef>, i16 %t1, i32 3
104
+ ; CHECK-NEXT: %t3 = insertelement <8 x i16> %t2, i16 0, i32 6
105
+ ; CHECK-NEXT: %t5 = shufflevector <8 x i16> %t3, <8 x i16> %[[WIDEVEC]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 11>
106
+ ; CHECK-NEXT: ret <8 x i16> %t5
107
+ ; CHECK: end:
108
+ ; CHECK-NEXT: %a1 = add i16 %t1, 4
109
+ ; CHECK-NEXT: %t6 = insertelement <8 x i16> <i16 undef, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>, i16 %a1, i32 0
110
+ ; CHECK-NEXT: ret <8 x i16> %t6
111
+
112
+ %t1 = extractelement <4 x i16 > %t0 , i32 2
113
+ br i1 %b , label %if , label %end
114
+
115
+ if:
116
+ %t2 = insertelement <8 x i16 > zeroinitializer , i16 %t1 , i32 3
117
+ %t3 = insertelement <8 x i16 > %t2 , i16 0 , i32 6
118
+ %t4 = extractelement <4 x i16 > %t0 , i32 3
119
+ %t5 = insertelement <8 x i16 > %t3 , i16 %t4 , i32 7
120
+ ret <8 x i16 > %t5
121
+
122
+ end:
123
+ %a1 = add i16 %t1 , 4
124
+ %t6 = insertelement <8 x i16 > zeroinitializer , i16 %a1 , i32 0
125
+ ret <8 x i16 > %t6
126
+ }
127
+
0 commit comments