llvm/llvm/test/Transforms/InstCombine/obfuscated_splat.ll

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
; RUN: opt -passes=instcombine -S < %s | FileCheck %s

define void @test_undef(ptr %in_ptr, ptr %out_ptr) {
; CHECK-LABEL: define void @test_undef(
; CHECK-SAME: ptr [[IN_PTR:%.*]], ptr [[OUT_PTR:%.*]]) {
; CHECK-NEXT:    [[A:%.*]] = load <4 x float>, ptr [[IN_PTR]], align 16
; CHECK-NEXT:    [[D:%.*]] = shufflevector <4 x float> [[A]], <4 x float> poison, <4 x i32> zeroinitializer
; CHECK-NEXT:    store <4 x float> [[D]], ptr [[OUT_PTR]], align 16
; CHECK-NEXT:    ret void
;
  %A = load <4 x float>, ptr %in_ptr, align 16
  %B = shufflevector <4 x float> %A, <4 x float> undef, <4 x i32> <i32 0, i32 0, i32 undef, i32 undef>
  %C = shufflevector <4 x float> %B, <4 x float> %A, <4 x i32> <i32 0, i32 1, i32 4, i32 undef>
  %D = shufflevector <4 x float> %C, <4 x float> %A, <4 x i32> <i32 0, i32 1, i32 2, i32 4>
  store <4 x float> %D, ptr %out_ptr
  ret void
}

define void @test_poison(ptr %in_ptr, ptr %out_ptr) {
; CHECK-LABEL: define void @test_poison(
; CHECK-SAME: ptr [[IN_PTR:%.*]], ptr [[OUT_PTR:%.*]]) {
; CHECK-NEXT:    [[A:%.*]] = load <4 x float>, ptr [[IN_PTR]], align 16
; CHECK-NEXT:    [[D:%.*]] = shufflevector <4 x float> [[A]], <4 x float> poison, <4 x i32> zeroinitializer
; CHECK-NEXT:    store <4 x float> [[D]], ptr [[OUT_PTR]], align 16
; CHECK-NEXT:    ret void
;
  %A = load <4 x float>, ptr %in_ptr, align 16
  %B = shufflevector <4 x float> %A, <4 x float> poison, <4 x i32> <i32 0, i32 0, i32 undef, i32 undef>
  %C = shufflevector <4 x float> %B, <4 x float> %A, <4 x i32> <i32 0, i32 1, i32 4, i32 undef>
  %D = shufflevector <4 x float> %C, <4 x float> %A, <4 x i32> <i32 0, i32 1, i32 2, i32 4>
  store <4 x float> %D, ptr %out_ptr
  ret void
}