1 ; RUN: opt -S -passes=instsimplify < %s | FileCheck %s
3 ; CHECK-LABEL: definitely_in_bounds
5 define i8 @definitely_in_bounds() {
6 ret i8 extractelement (<vscale x 16 x i8> zeroinitializer, i64 15)
9 ; CHECK-LABEL: maybe_in_bounds
10 ; CHECK: ret i8 extractelement (<vscale x 16 x i8> zeroinitializer, i64 16)
11 define i8 @maybe_in_bounds() {
12 ret i8 extractelement (<vscale x 16 x i8> zeroinitializer, i64 16)
15 ; Examples of extracting a lane from a splat constant
17 define i32 @extractconstant_shuffle_in_range(i32 %v) {
18 ; CHECK-LABEL: @extractconstant_shuffle_in_range(
19 ; CHECK-NEXT: ret i32 1024
21 %in = insertelement <vscale x 4 x i32> undef, i32 1024, i32 0
22 %splat = shufflevector <vscale x 4 x i32> %in, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
23 %r = extractelement <vscale x 4 x i32> %splat, i32 1
27 define i32 @extractconstant_shuffle_maybe_out_of_range(i32 %v) {
28 ; CHECK-LABEL: @extractconstant_shuffle_maybe_out_of_range(
29 ; CHECK-NEXT: ret i32 extractelement (<vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> undef, i32 1024, i32 0), <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer), i32 4)
31 %in = insertelement <vscale x 4 x i32> undef, i32 1024, i32 0
32 %splat = shufflevector <vscale x 4 x i32> %in, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
33 %r = extractelement <vscale x 4 x i32> %splat, i32 4
37 define i32 @extractconstant_shuffle_invalid_index(i32 %v) {
38 ; CHECK-LABEL: @extractconstant_shuffle_invalid_index(
39 ; CHECK-NEXT: ret i32 extractelement (<vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> undef, i32 1024, i32 0), <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer), i32 -1)
41 %in = insertelement <vscale x 4 x i32> undef, i32 1024, i32 0
42 %splat = shufflevector <vscale x 4 x i32> %in, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
43 %r = extractelement <vscale x 4 x i32> %splat, i32 -1