llvm.org GIT mirror llvm / d095a2f test / Transforms / InstSimplify / insertelement.ll
d095a2f

Tree @d095a2f (Download .tar.gz)

insertelement.ll @d095a2fraw · history · blame

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -instsimplify < %s | FileCheck %s

define <4 x i32> @test1(<4 x i32> %A) {
; CHECK-LABEL: @test1(
; CHECK-NEXT:    ret <4 x i32> undef
;
  %I = insertelement <4 x i32> %A, i32 5, i64 4294967296
  ret <4 x i32> %I
}

define <4 x i32> @test2(<4 x i32> %A) {
; CHECK-LABEL: @test2(
; CHECK-NEXT:    ret <4 x i32> undef
;
  %I = insertelement <4 x i32> %A, i32 5, i64 4
  ret <4 x i32> %I
}

define <4 x i32> @test3(<4 x i32> %A) {
; CHECK-LABEL: @test3(
; CHECK-NEXT:    [[I:%.*]] = insertelement <4 x i32> [[A:%.*]], i32 5, i64 1
; CHECK-NEXT:    ret <4 x i32> [[I]]
;
  %I = insertelement <4 x i32> %A, i32 5, i64 1
  ret <4 x i32> %I
}

define <4 x i32> @test4(<4 x i32> %A) {
; CHECK-LABEL: @test4(
; CHECK-NEXT:    ret <4 x i32> undef
;
  %I = insertelement <4 x i32> %A, i32 5, i128 100
  ret <4 x i32> %I
}

define <4 x i32> @test5(<4 x i32> %A) {
; CHECK-LABEL: @test5(
; CHECK-NEXT:    ret <4 x i32> undef
;
  %I = insertelement <4 x i32> %A, i32 5, i64 undef
  ret <4 x i32> %I
}

define <4 x i32> @PR1286(<4 x i32> %A) {
; CHECK-LABEL: @PR1286(
; CHECK-NEXT:    ret <4 x i32> [[A:%.*]]
;
  %B = insertelement <4 x i32> %A, i32 undef, i32 1
  ret <4 x i32> %B
}

define <8 x i8> @extract_insert_same_vec_and_index(<8 x i8> %in) {
; CHECK-LABEL: @extract_insert_same_vec_and_index(
; CHECK-NEXT:    [[VAL:%.*]] = extractelement <8 x i8> [[IN:%.*]], i32 5
; CHECK-NEXT:    [[VEC:%.*]] = insertelement <8 x i8> [[IN]], i8 [[VAL]], i32 5
; CHECK-NEXT:    ret <8 x i8> [[VEC]]
;
  %val = extractelement <8 x i8> %in, i32 5
  %vec = insertelement <8 x i8> %in, i8 %val, i32 5
  ret <8 x i8> %vec
}

define <8 x i8> @extract_insert_same_vec_and_index2(<8 x i8> %in, i32 %index) {
; CHECK-LABEL: @extract_insert_same_vec_and_index2(
; CHECK-NEXT:    [[VAL:%.*]] = extractelement <8 x i8> [[IN:%.*]], i32 [[INDEX:%.*]]
; CHECK-NEXT:    [[VEC:%.*]] = insertelement <8 x i8> [[IN]], i8 [[VAL]], i32 [[INDEX]]
; CHECK-NEXT:    ret <8 x i8> [[VEC]]
;
  %val = extractelement <8 x i8> %in, i32 %index
  %vec = insertelement <8 x i8> %in, i8 %val, i32 %index
  ret <8 x i8> %vec
}