1; Tests insertelement and extractelement vector instructions. 2 3; RUN: %p2i -i %s --insts | FileCheck %s 4; RUN: %l2i -i %s --insts | %ifl FileCheck %s 5; RUN: %lc2i -i %s --insts | %iflc FileCheck %s 6; RUN: %p2i -i %s --args -notranslate -timing | \ 7; RUN: FileCheck --check-prefix=NOIR %s 8 9define internal void @ExtractV4xi1(<4 x i1> %v) { 10entry: 11 %e0 = extractelement <4 x i1> %v, i32 0 12 %e1 = extractelement <4 x i1> %v, i32 1 13 %e2 = extractelement <4 x i1> %v, i32 2 14 %e3 = extractelement <4 x i1> %v, i32 3 15 ret void 16} 17 18; CHECK: define internal void @ExtractV4xi1(<4 x i1> %v) { 19; CHECK-NEXT: entry: 20; CHECK-NEXT: %e0 = extractelement <4 x i1> %v, i32 0 21; CHECK-NEXT: %e1 = extractelement <4 x i1> %v, i32 1 22; CHECK-NEXT: %e2 = extractelement <4 x i1> %v, i32 2 23; CHECK-NEXT: %e3 = extractelement <4 x i1> %v, i32 3 24; CHECK-NEXT: ret void 25; CHECK-NEXT: } 26 27define internal void @ExtractV8xi1(<8 x i1> %v) { 28entry: 29 %e0 = extractelement <8 x i1> %v, i32 0 30 %e1 = extractelement <8 x i1> %v, i32 1 31 %e2 = extractelement <8 x i1> %v, i32 2 32 %e3 = extractelement <8 x i1> %v, i32 3 33 %e4 = extractelement <8 x i1> %v, i32 4 34 %e5 = extractelement <8 x i1> %v, i32 5 35 %e6 = extractelement <8 x i1> %v, i32 6 36 %e7 = extractelement <8 x i1> %v, i32 7 37 ret void 38} 39 40; CHECK-NEXT: define internal void @ExtractV8xi1(<8 x i1> %v) { 41; CHECK-NEXT: entry: 42; CHECK-NEXT: %e0 = extractelement <8 x i1> %v, i32 0 43; CHECK-NEXT: %e1 = extractelement <8 x i1> %v, i32 1 44; CHECK-NEXT: %e2 = extractelement <8 x i1> %v, i32 2 45; CHECK-NEXT: %e3 = extractelement <8 x i1> %v, i32 3 46; CHECK-NEXT: %e4 = extractelement <8 x i1> %v, i32 4 47; CHECK-NEXT: %e5 = extractelement <8 x i1> %v, i32 5 48; CHECK-NEXT: %e6 = extractelement <8 x i1> %v, i32 6 49; CHECK-NEXT: %e7 = extractelement <8 x i1> %v, i32 7 50; CHECK-NEXT: ret void 51; CHECK-NEXT: } 52 53define internal void @ExtractV16xi1(<16 x i1> %v) { 54entry: 55 %e0 = extractelement <16 x i1> %v, i32 0 56 %e1 = extractelement <16 x i1> %v, i32 1 57 %e2 = extractelement <16 x i1> %v, i32 2 58 %e3 = extractelement <16 x i1> %v, i32 3 59 %e4 = extractelement <16 x i1> %v, i32 4 60 %e5 = extractelement <16 x i1> %v, i32 5 61 %e6 = extractelement <16 x i1> %v, i32 6 62 %e7 = extractelement <16 x i1> %v, i32 7 63 %e8 = extractelement <16 x i1> %v, i32 8 64 %e9 = extractelement <16 x i1> %v, i32 9 65 %e10 = extractelement <16 x i1> %v, i32 10 66 %e11 = extractelement <16 x i1> %v, i32 11 67 %e12 = extractelement <16 x i1> %v, i32 12 68 %e13 = extractelement <16 x i1> %v, i32 13 69 %e14 = extractelement <16 x i1> %v, i32 14 70 %e15 = extractelement <16 x i1> %v, i32 15 71 ret void 72} 73 74; CHECK-NEXT: define internal void @ExtractV16xi1(<16 x i1> %v) { 75; CHECK-NEXT: entry: 76; CHECK-NEXT: %e0 = extractelement <16 x i1> %v, i32 0 77; CHECK-NEXT: %e1 = extractelement <16 x i1> %v, i32 1 78; CHECK-NEXT: %e2 = extractelement <16 x i1> %v, i32 2 79; CHECK-NEXT: %e3 = extractelement <16 x i1> %v, i32 3 80; CHECK-NEXT: %e4 = extractelement <16 x i1> %v, i32 4 81; CHECK-NEXT: %e5 = extractelement <16 x i1> %v, i32 5 82; CHECK-NEXT: %e6 = extractelement <16 x i1> %v, i32 6 83; CHECK-NEXT: %e7 = extractelement <16 x i1> %v, i32 7 84; CHECK-NEXT: %e8 = extractelement <16 x i1> %v, i32 8 85; CHECK-NEXT: %e9 = extractelement <16 x i1> %v, i32 9 86; CHECK-NEXT: %e10 = extractelement <16 x i1> %v, i32 10 87; CHECK-NEXT: %e11 = extractelement <16 x i1> %v, i32 11 88; CHECK-NEXT: %e12 = extractelement <16 x i1> %v, i32 12 89; CHECK-NEXT: %e13 = extractelement <16 x i1> %v, i32 13 90; CHECK-NEXT: %e14 = extractelement <16 x i1> %v, i32 14 91; CHECK-NEXT: %e15 = extractelement <16 x i1> %v, i32 15 92; CHECK-NEXT: ret void 93; CHECK-NEXT: } 94 95define internal void @ExtractV16xi8(<16 x i8> %v, i32 %i) { 96entry: 97 %e0 = extractelement <16 x i8> %v, i32 0 98 %e1 = extractelement <16 x i8> %v, i32 1 99 %e2 = extractelement <16 x i8> %v, i32 2 100 %e3 = extractelement <16 x i8> %v, i32 3 101 %e4 = extractelement <16 x i8> %v, i32 4 102 %e5 = extractelement <16 x i8> %v, i32 5 103 %e6 = extractelement <16 x i8> %v, i32 6 104 %e7 = extractelement <16 x i8> %v, i32 7 105 %e8 = extractelement <16 x i8> %v, i32 8 106 %e9 = extractelement <16 x i8> %v, i32 9 107 %e10 = extractelement <16 x i8> %v, i32 10 108 %e11 = extractelement <16 x i8> %v, i32 11 109 %e12 = extractelement <16 x i8> %v, i32 12 110 %e13 = extractelement <16 x i8> %v, i32 13 111 %e14 = extractelement <16 x i8> %v, i32 14 112 %e15 = extractelement <16 x i8> %v, i32 15 113 ret void 114} 115 116; CHECK-NEXT: define internal void @ExtractV16xi8(<16 x i8> %v, i32 %i) { 117; CHECK-NEXT: entry: 118; CHECK-NEXT: %e0 = extractelement <16 x i8> %v, i32 0 119; CHECK-NEXT: %e1 = extractelement <16 x i8> %v, i32 1 120; CHECK-NEXT: %e2 = extractelement <16 x i8> %v, i32 2 121; CHECK-NEXT: %e3 = extractelement <16 x i8> %v, i32 3 122; CHECK-NEXT: %e4 = extractelement <16 x i8> %v, i32 4 123; CHECK-NEXT: %e5 = extractelement <16 x i8> %v, i32 5 124; CHECK-NEXT: %e6 = extractelement <16 x i8> %v, i32 6 125; CHECK-NEXT: %e7 = extractelement <16 x i8> %v, i32 7 126; CHECK-NEXT: %e8 = extractelement <16 x i8> %v, i32 8 127; CHECK-NEXT: %e9 = extractelement <16 x i8> %v, i32 9 128; CHECK-NEXT: %e10 = extractelement <16 x i8> %v, i32 10 129; CHECK-NEXT: %e11 = extractelement <16 x i8> %v, i32 11 130; CHECK-NEXT: %e12 = extractelement <16 x i8> %v, i32 12 131; CHECK-NEXT: %e13 = extractelement <16 x i8> %v, i32 13 132; CHECK-NEXT: %e14 = extractelement <16 x i8> %v, i32 14 133; CHECK-NEXT: %e15 = extractelement <16 x i8> %v, i32 15 134; CHECK-NEXT: ret void 135; CHECK-NEXT: } 136 137define internal void @ExtractV8xi16(<8 x i16> %v) { 138entry: 139 %e0 = extractelement <8 x i16> %v, i32 0 140 %e1 = extractelement <8 x i16> %v, i32 1 141 %e2 = extractelement <8 x i16> %v, i32 2 142 %e3 = extractelement <8 x i16> %v, i32 3 143 %e4 = extractelement <8 x i16> %v, i32 4 144 %e5 = extractelement <8 x i16> %v, i32 5 145 %e6 = extractelement <8 x i16> %v, i32 6 146 %e7 = extractelement <8 x i16> %v, i32 7 147 ret void 148} 149 150; CHECK-NEXT: define internal void @ExtractV8xi16(<8 x i16> %v) { 151; CHECK-NEXT: entry: 152; CHECK-NEXT: %e0 = extractelement <8 x i16> %v, i32 0 153; CHECK-NEXT: %e1 = extractelement <8 x i16> %v, i32 1 154; CHECK-NEXT: %e2 = extractelement <8 x i16> %v, i32 2 155; CHECK-NEXT: %e3 = extractelement <8 x i16> %v, i32 3 156; CHECK-NEXT: %e4 = extractelement <8 x i16> %v, i32 4 157; CHECK-NEXT: %e5 = extractelement <8 x i16> %v, i32 5 158; CHECK-NEXT: %e6 = extractelement <8 x i16> %v, i32 6 159; CHECK-NEXT: %e7 = extractelement <8 x i16> %v, i32 7 160; CHECK-NEXT: ret void 161; CHECK-NEXT: } 162 163define internal i32 @ExtractV4xi32(<4 x i32> %v) { 164entry: 165 %e0 = extractelement <4 x i32> %v, i32 0 166 %e1 = extractelement <4 x i32> %v, i32 1 167 %e2 = extractelement <4 x i32> %v, i32 2 168 %e3 = extractelement <4 x i32> %v, i32 3 169 ret i32 %e0 170} 171 172; CHECK-NEXT: define internal i32 @ExtractV4xi32(<4 x i32> %v) { 173; CHECK-NEXT: entry: 174; CHECK-NEXT: %e0 = extractelement <4 x i32> %v, i32 0 175; CHECK-NEXT: %e1 = extractelement <4 x i32> %v, i32 1 176; CHECK-NEXT: %e2 = extractelement <4 x i32> %v, i32 2 177; CHECK-NEXT: %e3 = extractelement <4 x i32> %v, i32 3 178; CHECK-NEXT: ret i32 %e0 179; CHECK-NEXT: } 180 181define internal float @ExtractV4xfloat(<4 x float> %v) { 182entry: 183 %e0 = extractelement <4 x float> %v, i32 0 184 %e1 = extractelement <4 x float> %v, i32 1 185 %e2 = extractelement <4 x float> %v, i32 2 186 %e3 = extractelement <4 x float> %v, i32 3 187 ret float %e0 188} 189 190; CHECK-NEXT: define internal float @ExtractV4xfloat(<4 x float> %v) { 191; CHECK-NEXT: entry: 192; CHECK-NEXT: %e0 = extractelement <4 x float> %v, i32 0 193; CHECK-NEXT: %e1 = extractelement <4 x float> %v, i32 1 194; CHECK-NEXT: %e2 = extractelement <4 x float> %v, i32 2 195; CHECK-NEXT: %e3 = extractelement <4 x float> %v, i32 3 196; CHECK-NEXT: ret float %e0 197; CHECK-NEXT: } 198 199define internal <4 x i1> @InsertV4xi1(<4 x i1> %v, i32 %pe) { 200entry: 201 %e = trunc i32 %pe to i1 202 %r0 = insertelement <4 x i1> %v, i1 %e, i32 0 203 %r1 = insertelement <4 x i1> %v, i1 %e, i32 1 204 %r2 = insertelement <4 x i1> %v, i1 %e, i32 2 205 %r3 = insertelement <4 x i1> %v, i1 %e, i32 3 206 ret <4 x i1> %r3 207} 208 209; CHECK-NEXT: define internal <4 x i1> @InsertV4xi1(<4 x i1> %v, i32 %pe) { 210; CHECK-NEXT: entry: 211; CHECK-NEXT: %e = trunc i32 %pe to i1 212; CHECK-NEXT: %r0 = insertelement <4 x i1> %v, i1 %e, i32 0 213; CHECK-NEXT: %r1 = insertelement <4 x i1> %v, i1 %e, i32 1 214; CHECK-NEXT: %r2 = insertelement <4 x i1> %v, i1 %e, i32 2 215; CHECK-NEXT: %r3 = insertelement <4 x i1> %v, i1 %e, i32 3 216; CHECK-NEXT: ret <4 x i1> %r3 217; CHECK-NEXT: } 218 219define internal <8 x i1> @InsertV8xi1(<8 x i1> %v, i32 %pe) { 220entry: 221 %e = trunc i32 %pe to i1 222 %r0 = insertelement <8 x i1> %v, i1 %e, i32 0 223 %r1 = insertelement <8 x i1> %v, i1 %e, i32 1 224 %r2 = insertelement <8 x i1> %v, i1 %e, i32 2 225 %r3 = insertelement <8 x i1> %v, i1 %e, i32 3 226 %r4 = insertelement <8 x i1> %v, i1 %e, i32 4 227 %r5 = insertelement <8 x i1> %v, i1 %e, i32 5 228 %r6 = insertelement <8 x i1> %v, i1 %e, i32 6 229 %r7 = insertelement <8 x i1> %v, i1 %e, i32 7 230 ret <8 x i1> %r7 231} 232 233; CHECK-NEXT: define internal <8 x i1> @InsertV8xi1(<8 x i1> %v, i32 %pe) { 234; CHECK-NEXT: entry: 235; CHECK-NEXT: %e = trunc i32 %pe to i1 236; CHECK-NEXT: %r0 = insertelement <8 x i1> %v, i1 %e, i32 0 237; CHECK-NEXT: %r1 = insertelement <8 x i1> %v, i1 %e, i32 1 238; CHECK-NEXT: %r2 = insertelement <8 x i1> %v, i1 %e, i32 2 239; CHECK-NEXT: %r3 = insertelement <8 x i1> %v, i1 %e, i32 3 240; CHECK-NEXT: %r4 = insertelement <8 x i1> %v, i1 %e, i32 4 241; CHECK-NEXT: %r5 = insertelement <8 x i1> %v, i1 %e, i32 5 242; CHECK-NEXT: %r6 = insertelement <8 x i1> %v, i1 %e, i32 6 243; CHECK-NEXT: %r7 = insertelement <8 x i1> %v, i1 %e, i32 7 244; CHECK-NEXT: ret <8 x i1> %r7 245; CHECK-NEXT: } 246 247define internal <16 x i1> @InsertV16xi1(<16 x i1> %v, i32 %pe) { 248entry: 249 %e = trunc i32 %pe to i1 250 %r0 = insertelement <16 x i1> %v, i1 %e, i32 0 251 %r1 = insertelement <16 x i1> %v, i1 %e, i32 1 252 %r2 = insertelement <16 x i1> %v, i1 %e, i32 2 253 %r3 = insertelement <16 x i1> %v, i1 %e, i32 3 254 %r4 = insertelement <16 x i1> %v, i1 %e, i32 4 255 %r5 = insertelement <16 x i1> %v, i1 %e, i32 5 256 %r6 = insertelement <16 x i1> %v, i1 %e, i32 6 257 %r7 = insertelement <16 x i1> %v, i1 %e, i32 7 258 %r8 = insertelement <16 x i1> %v, i1 %e, i32 8 259 %r9 = insertelement <16 x i1> %v, i1 %e, i32 9 260 %r10 = insertelement <16 x i1> %v, i1 %e, i32 10 261 %r11 = insertelement <16 x i1> %v, i1 %e, i32 11 262 %r12 = insertelement <16 x i1> %v, i1 %e, i32 12 263 %r13 = insertelement <16 x i1> %v, i1 %e, i32 13 264 %r14 = insertelement <16 x i1> %v, i1 %e, i32 14 265 %r15 = insertelement <16 x i1> %v, i1 %e, i32 15 266 ret <16 x i1> %r15 267} 268 269; CHECK-NEXT: define internal <16 x i1> @InsertV16xi1(<16 x i1> %v, i32 %pe) { 270; CHECK-NEXT: entry: 271; CHECK-NEXT: %e = trunc i32 %pe to i1 272; CHECK-NEXT: %r0 = insertelement <16 x i1> %v, i1 %e, i32 0 273; CHECK-NEXT: %r1 = insertelement <16 x i1> %v, i1 %e, i32 1 274; CHECK-NEXT: %r2 = insertelement <16 x i1> %v, i1 %e, i32 2 275; CHECK-NEXT: %r3 = insertelement <16 x i1> %v, i1 %e, i32 3 276; CHECK-NEXT: %r4 = insertelement <16 x i1> %v, i1 %e, i32 4 277; CHECK-NEXT: %r5 = insertelement <16 x i1> %v, i1 %e, i32 5 278; CHECK-NEXT: %r6 = insertelement <16 x i1> %v, i1 %e, i32 6 279; CHECK-NEXT: %r7 = insertelement <16 x i1> %v, i1 %e, i32 7 280; CHECK-NEXT: %r8 = insertelement <16 x i1> %v, i1 %e, i32 8 281; CHECK-NEXT: %r9 = insertelement <16 x i1> %v, i1 %e, i32 9 282; CHECK-NEXT: %r10 = insertelement <16 x i1> %v, i1 %e, i32 10 283; CHECK-NEXT: %r11 = insertelement <16 x i1> %v, i1 %e, i32 11 284; CHECK-NEXT: %r12 = insertelement <16 x i1> %v, i1 %e, i32 12 285; CHECK-NEXT: %r13 = insertelement <16 x i1> %v, i1 %e, i32 13 286; CHECK-NEXT: %r14 = insertelement <16 x i1> %v, i1 %e, i32 14 287; CHECK-NEXT: %r15 = insertelement <16 x i1> %v, i1 %e, i32 15 288; CHECK-NEXT: ret <16 x i1> %r15 289; CHECK-NEXT: } 290 291define internal <16 x i8> @InsertV16xi8(<16 x i8> %v, i32 %pe) { 292entry: 293 %e = trunc i32 %pe to i8 294 %r0 = insertelement <16 x i8> %v, i8 %e, i32 0 295 %r1 = insertelement <16 x i8> %v, i8 %e, i32 1 296 %r2 = insertelement <16 x i8> %v, i8 %e, i32 2 297 %r3 = insertelement <16 x i8> %v, i8 %e, i32 3 298 %r4 = insertelement <16 x i8> %v, i8 %e, i32 4 299 %r5 = insertelement <16 x i8> %v, i8 %e, i32 5 300 %r6 = insertelement <16 x i8> %v, i8 %e, i32 6 301 %r7 = insertelement <16 x i8> %v, i8 %e, i32 7 302 ret <16 x i8> %r7 303} 304 305; CHECK-NEXT: define internal <16 x i8> @InsertV16xi8(<16 x i8> %v, i32 %pe) { 306; CHECK-NEXT: entry: 307; CHECK-NEXT: %e = trunc i32 %pe to i8 308; CHECK-NEXT: %r0 = insertelement <16 x i8> %v, i8 %e, i32 0 309; CHECK-NEXT: %r1 = insertelement <16 x i8> %v, i8 %e, i32 1 310; CHECK-NEXT: %r2 = insertelement <16 x i8> %v, i8 %e, i32 2 311; CHECK-NEXT: %r3 = insertelement <16 x i8> %v, i8 %e, i32 3 312; CHECK-NEXT: %r4 = insertelement <16 x i8> %v, i8 %e, i32 4 313; CHECK-NEXT: %r5 = insertelement <16 x i8> %v, i8 %e, i32 5 314; CHECK-NEXT: %r6 = insertelement <16 x i8> %v, i8 %e, i32 6 315; CHECK-NEXT: %r7 = insertelement <16 x i8> %v, i8 %e, i32 7 316; CHECK-NEXT: ret <16 x i8> %r7 317; CHECK-NEXT: } 318 319define internal <8 x i16> @InsertV8xi16(<8 x i16> %v, i32 %pe) { 320entry: 321 %e = trunc i32 %pe to i16 322 %r0 = insertelement <8 x i16> %v, i16 %e, i32 0 323 %r1 = insertelement <8 x i16> %v, i16 %e, i32 1 324 %r2 = insertelement <8 x i16> %v, i16 %e, i32 2 325 %r3 = insertelement <8 x i16> %v, i16 %e, i32 3 326 %r4 = insertelement <8 x i16> %v, i16 %e, i32 4 327 %r5 = insertelement <8 x i16> %v, i16 %e, i32 5 328 %r6 = insertelement <8 x i16> %v, i16 %e, i32 6 329 %r7 = insertelement <8 x i16> %v, i16 %e, i32 7 330 ret <8 x i16> %r7 331} 332 333; CHECK-NEXT: define internal <8 x i16> @InsertV8xi16(<8 x i16> %v, i32 %pe) { 334; CHECK-NEXT: entry: 335; CHECK-NEXT: %e = trunc i32 %pe to i16 336; CHECK-NEXT: %r0 = insertelement <8 x i16> %v, i16 %e, i32 0 337; CHECK-NEXT: %r1 = insertelement <8 x i16> %v, i16 %e, i32 1 338; CHECK-NEXT: %r2 = insertelement <8 x i16> %v, i16 %e, i32 2 339; CHECK-NEXT: %r3 = insertelement <8 x i16> %v, i16 %e, i32 3 340; CHECK-NEXT: %r4 = insertelement <8 x i16> %v, i16 %e, i32 4 341; CHECK-NEXT: %r5 = insertelement <8 x i16> %v, i16 %e, i32 5 342; CHECK-NEXT: %r6 = insertelement <8 x i16> %v, i16 %e, i32 6 343; CHECK-NEXT: %r7 = insertelement <8 x i16> %v, i16 %e, i32 7 344; CHECK-NEXT: ret <8 x i16> %r7 345; CHECK-NEXT: } 346 347define internal <4 x i32> @InsertV4xi32(<4 x i32> %v, i32 %e) { 348entry: 349 %r0 = insertelement <4 x i32> %v, i32 %e, i32 0 350 %r1 = insertelement <4 x i32> %v, i32 %e, i32 1 351 %r2 = insertelement <4 x i32> %v, i32 %e, i32 2 352 %r3 = insertelement <4 x i32> %v, i32 %e, i32 3 353 ret <4 x i32> %r3 354} 355 356; CHECK-NEXT: define internal <4 x i32> @InsertV4xi32(<4 x i32> %v, i32 %e) { 357; CHECK-NEXT: entry: 358; CHECK-NEXT: %r0 = insertelement <4 x i32> %v, i32 %e, i32 0 359; CHECK-NEXT: %r1 = insertelement <4 x i32> %v, i32 %e, i32 1 360; CHECK-NEXT: %r2 = insertelement <4 x i32> %v, i32 %e, i32 2 361; CHECK-NEXT: %r3 = insertelement <4 x i32> %v, i32 %e, i32 3 362; CHECK-NEXT: ret <4 x i32> %r3 363; CHECK-NEXT: } 364 365define internal <4 x float> @InsertV4xfloat(<4 x float> %v, float %e) { 366entry: 367 %r0 = insertelement <4 x float> %v, float %e, i32 0 368 %r1 = insertelement <4 x float> %v, float %e, i32 1 369 %r2 = insertelement <4 x float> %v, float %e, i32 2 370 %r3 = insertelement <4 x float> %v, float %e, i32 3 371 ret <4 x float> %r3 372} 373 374; CHECK-NEXT: define internal <4 x float> @InsertV4xfloat(<4 x float> %v, float %e) { 375; CHECK-NEXT: entry: 376; CHECK-NEXT: %r0 = insertelement <4 x float> %v, float %e, i32 0 377; CHECK-NEXT: %r1 = insertelement <4 x float> %v, float %e, i32 1 378; CHECK-NEXT: %r2 = insertelement <4 x float> %v, float %e, i32 2 379; CHECK-NEXT: %r3 = insertelement <4 x float> %v, float %e, i32 3 380; CHECK-NEXT: ret <4 x float> %r3 381; CHECK-NEXT: } 382 383; NOIR: Total across all functions 384