1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2 ; RUN: opt -S -passes=instsimplify < %s | FileCheck %s
4 define i8 @definitely_in_bounds() {
5 ; CHECK-LABEL: define i8 @definitely_in_bounds() {
8 ret i8 extractelement (<vscale x 16 x i8> zeroinitializer, i64 15)
11 define i8 @maybe_in_bounds() {
12 ; CHECK-LABEL: define i8 @maybe_in_bounds() {
13 ; CHECK-NEXT: ret i8 extractelement (<vscale x 16 x i8> zeroinitializer, i64 16)
15 ret i8 extractelement (<vscale x 16 x i8> zeroinitializer, i64 16)
18 ; Examples of extracting a lane from a splat constant
20 define i32 @extractconstant_shuffle_in_range(i32 %v) {
21 ; CHECK-LABEL: define i32 @extractconstant_shuffle_in_range(
22 ; CHECK-SAME: i32 [[V:%.*]]) {
23 ; CHECK-NEXT: ret i32 1024
25 %in = insertelement <vscale x 4 x i32> undef, i32 1024, i32 0
26 %splat = shufflevector <vscale x 4 x i32> %in, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
27 %r = extractelement <vscale x 4 x i32> %splat, i32 1
31 define i32 @extractconstant_shuffle_maybe_out_of_range(i32 %v) {
32 ; CHECK-LABEL: define i32 @extractconstant_shuffle_maybe_out_of_range(
33 ; CHECK-SAME: i32 [[V:%.*]]) {
34 ; CHECK-NEXT: ret i32 extractelement (<vscale x 4 x i32> splat (i32 1024), i32 4)
36 %in = insertelement <vscale x 4 x i32> undef, i32 1024, i32 0
37 %splat = shufflevector <vscale x 4 x i32> %in, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
38 %r = extractelement <vscale x 4 x i32> %splat, i32 4
42 define i32 @extractconstant_shuffle_invalid_index(i32 %v) {
43 ; CHECK-LABEL: define i32 @extractconstant_shuffle_invalid_index(
44 ; CHECK-SAME: i32 [[V:%.*]]) {
45 ; CHECK-NEXT: ret i32 extractelement (<vscale x 4 x i32> splat (i32 1024), i32 -1)
47 %in = insertelement <vscale x 4 x i32> undef, i32 1024, i32 0
48 %splat = shufflevector <vscale x 4 x i32> %in, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
49 %r = extractelement <vscale x 4 x i32> %splat, i32 -1