1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -instsimplify < %s | FileCheck %s
4 define <4 x i32> @test1(<4 x i32> %A) {
6 ; CHECK-NEXT: ret <4 x i32> undef
8 %I = insertelement <4 x i32> %A, i32 5, i64 4294967296
12 define <4 x i32> @test2(<4 x i32> %A) {
13 ; CHECK-LABEL: @test2(
14 ; CHECK-NEXT: ret <4 x i32> undef
16 %I = insertelement <4 x i32> %A, i32 5, i64 4
20 define <4 x i32> @test3(<4 x i32> %A) {
21 ; CHECK-LABEL: @test3(
22 ; CHECK-NEXT: [[I:%.*]] = insertelement <4 x i32> [[A:%.*]], i32 5, i64 1
23 ; CHECK-NEXT: ret <4 x i32> [[I]]
25 %I = insertelement <4 x i32> %A, i32 5, i64 1
29 define <4 x i32> @test4(<4 x i32> %A) {
30 ; CHECK-LABEL: @test4(
31 ; CHECK-NEXT: ret <4 x i32> undef
33 %I = insertelement <4 x i32> %A, i32 5, i128 100
37 define <4 x i32> @test5(<4 x i32> %A) {
38 ; CHECK-LABEL: @test5(
39 ; CHECK-NEXT: ret <4 x i32> undef
41 %I = insertelement <4 x i32> %A, i32 5, i64 undef
45 define <4 x i32> @PR1286(<4 x i32> %A) {
46 ; CHECK-LABEL: @PR1286(
47 ; CHECK-NEXT: ret <4 x i32> [[A:%.*]]
49 %B = insertelement <4 x i32> %A, i32 undef, i32 1
53 define <8 x i8> @extract_insert_same_vec_and_index(<8 x i8> %in) {
54 ; CHECK-LABEL: @extract_insert_same_vec_and_index(
55 ; CHECK-NEXT: ret <8 x i8> [[IN:%.*]]
57 %val = extractelement <8 x i8> %in, i32 5
58 %vec = insertelement <8 x i8> %in, i8 %val, i32 5
62 define <8 x i8> @extract_insert_same_vec_and_index2(<8 x i8> %in, i32 %index) {
63 ; CHECK-LABEL: @extract_insert_same_vec_and_index2(
64 ; CHECK-NEXT: ret <8 x i8> [[IN:%.*]]
66 %val = extractelement <8 x i8> %in, i32 %index
67 %vec = insertelement <8 x i8> %in, i8 %val, i32 %index
71 ; The insert is in an unreachable block, so it is allowed to point to itself.
72 ; This would crash via stack overflow.
74 define void @PR43218() {
75 ; CHECK-LABEL: @PR43218(
77 ; CHECK-NEXT: ret void
78 ; CHECK: unreachable_infloop:
79 ; CHECK-NEXT: [[EXTRACT:%.*]] = extractelement <2 x i64> [[BOGUS:%.*]], i32 0
80 ; CHECK-NEXT: [[T0:%.*]] = inttoptr i64 [[EXTRACT]] to i16****
81 ; CHECK-NEXT: [[BOGUS]] = insertelement <2 x i64> [[BOGUS]], i64 undef, i32 1
82 ; CHECK-NEXT: br label [[UNREACHABLE_INFLOOP:%.*]]
88 %extract = extractelement <2 x i64> %bogus, i32 0
89 %t0 = inttoptr i64 %extract to i16****
90 %bogus = insertelement <2 x i64> %bogus, i64 undef, i32 1
91 br label %unreachable_infloop