1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
6 ; CHECK-NEXT: ret i32 2139171423
8 %A = bitcast i32 2139171423 to float
9 %B = insertelement <1 x float> undef, float %A, i32 0
10 %C = extractelement <1 x float> %B, i32 0
11 %D = bitcast float %C to i32
15 define <4 x i64> @insertelement() {
16 ; CHECK-LABEL: @insertelement(
17 ; CHECK-NEXT: ret <4 x i64> <i64 -1, i64 -2, i64 -3, i64 -4>
19 %vec1 = insertelement <4 x i64> undef, i64 -1, i32 0
20 %vec2 = insertelement <4 x i64> %vec1, i64 -2, i32 1
21 %vec3 = insertelement <4 x i64> %vec2, i64 -3, i32 2
22 %vec4 = insertelement <4 x i64> %vec3, i64 -4, i32 3
26 define <4 x i64> @insertelement_undef() {
27 ; CHECK-LABEL: @insertelement_undef(
28 ; CHECK-NEXT: ret <4 x i64> poison
30 %vec1 = insertelement <4 x i64> undef, i64 -1, i32 0
31 %vec2 = insertelement <4 x i64> %vec1, i64 -2, i32 1
32 %vec3 = insertelement <4 x i64> %vec2, i64 -3, i32 2
33 %vec4 = insertelement <4 x i64> %vec3, i64 -4, i32 3
34 %vec5 = insertelement <4 x i64> %vec3, i64 -5, i32 4
38 define i64 @extract_undef_index_from_zero_vec() {
39 ; CHECK-LABEL: @extract_undef_index_from_zero_vec(
40 ; CHECK-NEXT: ret i64 poison
42 %E = extractelement <2 x i64> zeroinitializer, i64 undef
46 define i64 @extract_undef_index_from_nonzero_vec() {
47 ; CHECK-LABEL: @extract_undef_index_from_nonzero_vec(
48 ; CHECK-NEXT: ret i64 poison
50 %E = extractelement <2 x i64> <i64 -1, i64 -1>, i64 undef
54 define <vscale x 2 x i32> @insertelement_scalable_null() {
55 ; CHECK-LABEL: @insertelement_scalable_null(
56 ; CHECK-NEXT: ret <vscale x 2 x i32> zeroinitializer
58 %vec = insertelement <vscale x 2 x i32> zeroinitializer, i32 0, i32 0
59 ret <vscale x 2 x i32> %vec
62 define <vscale x 2 x float> @insertelement_scalable_null_fp() {
63 ; CHECK-LABEL: @insertelement_scalable_null_fp(
64 ; CHECK-NEXT: ret <vscale x 2 x float> zeroinitializer
66 %vec = insertelement <vscale x 2 x float> zeroinitializer, float 0.0, i32 1
67 ret <vscale x 2 x float> %vec