xref: /llvm-project/llvm/test/Transforms/InstSimplify/vector-inseltextelt.ll (revision 021e6e05d3d966d2291434fec1ec5d6db5633963)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
3
4; extracting a just-inserted element should yield the original value
5define float @constant_index(<4 x float> %x, float %val) {
6; CHECK-LABEL: @constant_index(
7; CHECK-NEXT:    ret float [[VAL:%.*]]
8;
9  %ins = insertelement <4 x float> %x, float %val, i32 1
10  %ext = extractelement <4 x float> %ins, i32 1
11  ret float %ext
12}
13
14; extracting a just-inserted element should yield the original value even if
15; the index is dynamic
16define float @dynamic_index(<4 x float> %x, float %val, i32 %idx) {
17; CHECK-LABEL: @dynamic_index(
18; CHECK-NEXT:    ret float [[VAL:%.*]]
19;
20  %ins = insertelement <4 x float> %x, float %val, i32 %idx
21  %ext = extractelement <4 x float> %ins, i32 %idx
22  ret float %ext
23}
24