[llvm] c1b6103 - [NFC] Remove 'br i1 undef' from SROA tests

Nuno Lopes via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 12 07:30:18 PDT 2022


Author: Nuno Lopes
Date: 2022-06-12T15:29:59+01:00
New Revision: c1b610307df22d12687bde26919e45752c33ab0b

URL: https://github.com/llvm/llvm-project/commit/c1b610307df22d12687bde26919e45752c33ab0b
DIFF: https://github.com/llvm/llvm-project/commit/c1b610307df22d12687bde26919e45752c33ab0b.diff

LOG: [NFC] Remove 'br i1 undef' from SROA tests

Added: 
    

Modified: 
    llvm/test/Transforms/SROA/address-spaces.ll
    llvm/test/Transforms/SROA/addrspacecast.ll
    llvm/test/Transforms/SROA/alloca-address-space.ll
    llvm/test/Transforms/SROA/assume.ll
    llvm/test/Transforms/SROA/basictest-opaque-ptrs.ll
    llvm/test/Transforms/SROA/basictest.ll
    llvm/test/Transforms/SROA/dbg-single-piece.ll
    llvm/test/Transforms/SROA/dead-inst.ll
    llvm/test/Transforms/SROA/fca.ll
    llvm/test/Transforms/SROA/phi-and-select.ll
    llvm/test/Transforms/SROA/phi-gep.ll
    llvm/test/Transforms/SROA/phi-with-duplicate-pred.ll
    llvm/test/Transforms/SROA/select-gep.ll
    llvm/test/Transforms/SROA/select-load.ll
    llvm/test/Transforms/SROA/vector-promotion-different-size.ll
    llvm/test/Transforms/SROA/vector-promotion.ll
    llvm/test/Transforms/SROA/vectors-of-pointers.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/SROA/address-spaces.ll b/llvm/test/Transforms/SROA/address-spaces.ll
index 4303a924595a5..c7e907827ea8e 100644
--- a/llvm/test/Transforms/SROA/address-spaces.ll
+++ b/llvm/test/Transforms/SROA/address-spaces.ll
@@ -52,8 +52,7 @@ define void @test_address_space_0_1(<2 x i64>* %a, i16 addrspace(1)* %b) {
 
 %struct.struct_test_27.0.13 = type { i32, float, i64, i8, [4 x i32] }
 
-; Function Attrs: nounwind
-define void @copy_struct([5 x i64] %in.coerce) {
+define void @copy_struct([5 x i64] %in.coerce, i8 addrspace(1)* align 4 %ptr) {
 ; CHECK-LABEL: @copy_struct(
 ; CHECK-NOT: memcpy
 for.end:
@@ -62,7 +61,7 @@ for.end:
   store [5 x i64] %in.coerce, [5 x i64]* %0, align 8
   %scevgep9 = getelementptr %struct.struct_test_27.0.13, %struct.struct_test_27.0.13* %in, i32 0, i32 4, i32 0
   %scevgep910 = bitcast i32* %scevgep9 to i8*
-  call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* align 4 undef, i8* align 4 %scevgep910, i32 16, i1 false)
+  call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* align 4 %ptr, i8* align 4 %scevgep910, i32 16, i1 false)
   ret void
 }
  

diff  --git a/llvm/test/Transforms/SROA/addrspacecast.ll b/llvm/test/Transforms/SROA/addrspacecast.ll
index 612d65ea2c5b0..aed08f8ebe563 100644
--- a/llvm/test/Transforms/SROA/addrspacecast.ll
+++ b/llvm/test/Transforms/SROA/addrspacecast.ll
@@ -256,10 +256,10 @@ define void @select_addrspacecast(i1 %a, i1 %b) {
 ; CHECK-NEXT:    ret void
 ;
   %c = alloca i64, align 8
-  %p.0.c = select i1 undef, i64* %c, i64* %c
+  %p.0.c = select i1 %a, i64* %c, i64* %c
   %asc = addrspacecast i64* %p.0.c to i64 addrspace(1)*
 
-  %cond.in = select i1 undef, i64 addrspace(1)* %asc, i64 addrspace(1)* %asc
+  %cond.in = select i1 %b, i64 addrspace(1)* %asc, i64 addrspace(1)* %asc
   %cond = load i64, i64 addrspace(1)* %cond.in, align 8
   ret void
 }
@@ -268,15 +268,15 @@ define void @select_addrspacecast_const_op(i1 %a, i1 %b) {
 ; CHECK-LABEL: @select_addrspacecast_const_op(
 ; CHECK-NEXT:    [[C:%.*]] = alloca i64, align 8
 ; CHECK-NEXT:    [[C_0_ASC_SROA_CAST:%.*]] = addrspacecast i64* [[C]] to i64 addrspace(1)*
-; CHECK-NEXT:    [[COND_IN:%.*]] = select i1 undef, i64 addrspace(1)* [[C_0_ASC_SROA_CAST]], i64 addrspace(1)* null
+; CHECK-NEXT:    [[COND_IN:%.*]] = select i1 [[B:%.*]], i64 addrspace(1)* [[C_0_ASC_SROA_CAST]], i64 addrspace(1)* null
 ; CHECK-NEXT:    [[COND:%.*]] = load i64, i64 addrspace(1)* [[COND_IN]], align 8
 ; CHECK-NEXT:    ret void
 ;
   %c = alloca i64, align 8
-  %p.0.c = select i1 undef, i64* %c, i64* %c
+  %p.0.c = select i1 %a, i64* %c, i64* %c
   %asc = addrspacecast i64* %p.0.c to i64 addrspace(1)*
 
-  %cond.in = select i1 undef, i64 addrspace(1)* %asc, i64 addrspace(1)* null
+  %cond.in = select i1 %b, i64 addrspace(1)* %asc, i64 addrspace(1)* null
   %cond = load i64, i64 addrspace(1)* %cond.in, align 8
   ret void
 }
@@ -288,14 +288,14 @@ define void @select_addrspacecast_const_op(i1 %a, i1 %b) {
 define void @select_addrspacecast_gv(i1 %a, i1 %b) {
 ; CHECK-LABEL: @select_addrspacecast_gv(
 ; CHECK-NEXT:    [[COND_SROA_SPECULATE_LOAD_FALSE:%.*]] = load i64, i64 addrspace(1)* @gv, align 8
-; CHECK-NEXT:    [[COND_SROA_SPECULATED:%.*]] = select i1 undef, i64 undef, i64 [[COND_SROA_SPECULATE_LOAD_FALSE]]
+; CHECK-NEXT:    [[COND_SROA_SPECULATED:%.*]] = select i1 [[B:%.*]], i64 undef, i64 [[COND_SROA_SPECULATE_LOAD_FALSE]]
 ; CHECK-NEXT:    ret void
 ;
   %c = alloca i64, align 8
-  %p.0.c = select i1 undef, i64* %c, i64* %c
+  %p.0.c = select i1 %a, i64* %c, i64* %c
   %asc = addrspacecast i64* %p.0.c to i64 addrspace(1)*
 
-  %cond.in = select i1 undef, i64 addrspace(1)* %asc, i64 addrspace(1)* @gv
+  %cond.in = select i1 %b, i64 addrspace(1)* %asc, i64 addrspace(1)* @gv
   %cond = load i64, i64 addrspace(1)* %cond.in, align 8
   ret void
 }
@@ -303,21 +303,21 @@ define void @select_addrspacecast_gv(i1 %a, i1 %b) {
 define void @select_addrspacecast_gv_constexpr(i1 %a, i1 %b) {
 ; CHECK-LABEL: @select_addrspacecast_gv_constexpr(
 ; CHECK-NEXT:    [[COND_SROA_SPECULATE_LOAD_FALSE:%.*]] = load i64, i64 addrspace(2)* addrspacecast (i64 addrspace(1)* @gv to i64 addrspace(2)*), align 8
-; CHECK-NEXT:    [[COND_SROA_SPECULATED:%.*]] = select i1 undef, i64 undef, i64 [[COND_SROA_SPECULATE_LOAD_FALSE]]
+; CHECK-NEXT:    [[COND_SROA_SPECULATED:%.*]] = select i1 [[B:%.*]], i64 undef, i64 [[COND_SROA_SPECULATE_LOAD_FALSE]]
 ; CHECK-NEXT:    ret void
 ;
   %c = alloca i64, align 8
-  %p.0.c = select i1 undef, i64* %c, i64* %c
+  %p.0.c = select i1 %a, i64* %c, i64* %c
   %asc = addrspacecast i64* %p.0.c to i64 addrspace(2)*
 
-  %cond.in = select i1 undef, i64 addrspace(2)* %asc, i64 addrspace(2)* addrspacecast (i64 addrspace(1)* @gv to i64 addrspace(2)*)
+  %cond.in = select i1 %b, i64 addrspace(2)* %asc, i64 addrspace(2)* addrspacecast (i64 addrspace(1)* @gv to i64 addrspace(2)*)
   %cond = load i64, i64 addrspace(2)* %cond.in, align 8
   ret void
 }
 
-define i8 @select_addrspacecast_i8() {
+define i8 @select_addrspacecast_i8(i1 %c) {
 ; CHECK-LABEL: @select_addrspacecast_i8(
-; CHECK-NEXT:    [[RET_SROA_SPECULATED:%.*]] = select i1 undef, i8 undef, i8 undef
+; CHECK-NEXT:    [[RET_SROA_SPECULATED:%.*]] = select i1 [[C:%.*]], i8 undef, i8 undef
 ; CHECK-NEXT:    ret i8 [[RET_SROA_SPECULATED]]
 ;
   %a = alloca i8
@@ -326,7 +326,7 @@ define i8 @select_addrspacecast_i8() {
   %a.ptr = addrspacecast i8* %a to i8 addrspace(1)*
   %b.ptr = addrspacecast i8* %b to i8 addrspace(1)*
 
-  %ptr = select i1 undef, i8 addrspace(1)* %a.ptr, i8 addrspace(1)* %b.ptr
+  %ptr = select i1 %c, i8 addrspace(1)* %a.ptr, i8 addrspace(1)* %b.ptr
   %ret = load i8, i8 addrspace(1)* %ptr
   ret i8 %ret
 }

diff  --git a/llvm/test/Transforms/SROA/alloca-address-space.ll b/llvm/test/Transforms/SROA/alloca-address-space.ll
index 03f4500e65d9d..fa0fc24eed194 100644
--- a/llvm/test/Transforms/SROA/alloca-address-space.ll
+++ b/llvm/test/Transforms/SROA/alloca-address-space.ll
@@ -54,14 +54,14 @@ define void @test_address_space_0_1(<2 x i64> addrspace(2)* %a, i16 addrspace(1)
 
 ; CHECK-LABEL: @copy_struct(
 ; CHECK-NOT: memcpy
-define void @copy_struct([5 x i64] %in.coerce) {
+define void @copy_struct([5 x i64] %in.coerce, i8 addrspace(1)* align 4 %ptr) {
 for.end:
   %in = alloca %struct.struct_test_27.0.13, align 8, addrspace(2)
   %0 = bitcast %struct.struct_test_27.0.13 addrspace(2)* %in to [5 x i64] addrspace(2)*
   store [5 x i64] %in.coerce, [5 x i64] addrspace(2)* %0, align 8
   %scevgep9 = getelementptr %struct.struct_test_27.0.13, %struct.struct_test_27.0.13 addrspace(2)* %in, i32 0, i32 4, i32 0
   %scevgep910 = bitcast i32 addrspace(2)* %scevgep9 to i8 addrspace(2)*
-  call void @llvm.memcpy.p1i8.p2i8.i32(i8 addrspace(1)* align 4 undef, i8 addrspace(2)* align 4 %scevgep910, i32 16, i1 false)
+  call void @llvm.memcpy.p1i8.p2i8.i32(i8 addrspace(1)* align 4 %ptr, i8 addrspace(2)* align 4 %scevgep910, i32 16, i1 false)
   ret void
 }
 

diff  --git a/llvm/test/Transforms/SROA/assume.ll b/llvm/test/Transforms/SROA/assume.ll
index 2c24e2f05e9b5..9043d49dce9bf 100644
--- a/llvm/test/Transforms/SROA/assume.ll
+++ b/llvm/test/Transforms/SROA/assume.ll
@@ -1,7 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt < %s -passes=sroa -S | FileCheck %s
 
-source_filename = "tmp.cpp"
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
@@ -11,7 +10,7 @@ target triple = "x86_64-unknown-linux-gnu"
 %class.ao = type { %class.ai }
 %class.ai = type { i32, i32 }
 
-define linkonce_odr dso_local void @_ZN2bg2baIiEC2ES_() unnamed_addr align 2 {
+define void @_ZN2bg2baIiEC2ES_(i64 %v) {
 ; CHECK-LABEL: @_ZN2bg2baIiEC2ES_(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    call void @llvm.assume(i1 true) [ "ignore"(%struct.bi* undef) ]
@@ -19,7 +18,7 @@ define linkonce_odr dso_local void @_ZN2bg2baIiEC2ES_() unnamed_addr align 2 {
 ;
 entry:
   %y = alloca i64, align 8
-  store i64 undef, i64* %y, align 8
+  store i64 %v, i64* %y, align 8
   %0 = bitcast i64* %y to %struct.n.2*
   %1 = bitcast %struct.n.2* %0 to %struct.bi*
   call void @llvm.assume(i1 true) [ "nonnull"(%struct.bi* %1) ]

diff  --git a/llvm/test/Transforms/SROA/basictest-opaque-ptrs.ll b/llvm/test/Transforms/SROA/basictest-opaque-ptrs.ll
index 339149ba345f4..a524adda403e0 100644
--- a/llvm/test/Transforms/SROA/basictest-opaque-ptrs.ll
+++ b/llvm/test/Transforms/SROA/basictest-opaque-ptrs.ll
@@ -515,7 +515,7 @@ define %S2 @test8(%S2* %arg) {
 ; CHECK-NEXT:    [[S2_NEXT_S1:%.*]] = load ptr, ptr [[S2_NEXT_S1_PTR]], align 8, !tbaa [[TBAA3]]
 ; CHECK-NEXT:    [[S2_NEXT_NEXT_PTR:%.*]] = getelementptr [[S2]], ptr [[S2_NEXT]], i64 0, i32 1
 ; CHECK-NEXT:    [[S2_NEXT_NEXT:%.*]] = load ptr, ptr [[S2_NEXT_NEXT_PTR]], align 8, !tbaa [[TBAA7]]
-; CHECK-NEXT:    [[RESULT1:%.*]] = insertvalue [[S2]] undef, ptr [[S2_NEXT_S1]], 0
+; CHECK-NEXT:    [[RESULT1:%.*]] = insertvalue [[S2]] poison, ptr [[S2_NEXT_S1]], 0
 ; CHECK-NEXT:    [[RESULT2:%.*]] = insertvalue [[S2]] [[RESULT1]], ptr [[S2_NEXT_NEXT]], 1
 ; CHECK-NEXT:    ret [[S2]] [[RESULT2]]
 ;
@@ -535,7 +535,7 @@ entry:
   store %S2* %s2.next.next, %S2** %new.next.ptr, !tbaa !9
 
   %new.s1 = load %S1*, %S1** %new.s1.ptr
-  %result1 = insertvalue %S2 undef, %S1* %new.s1, 0
+  %result1 = insertvalue %S2 poison, %S1* %new.s1, 0
   %new.next = load %S2*, %S2** %new.next.ptr
   %result2 = insertvalue %S2 %result1, %S2* %new.next, 1
   ret %S2 %result2
@@ -594,10 +594,10 @@ entry:
   ret %S2* %s2ptr
 }
 
-define i32 @test11() {
+define i32 @test11(i1 %c) {
 ; CHECK-LABEL: @test11(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 undef, label [[GOOD:%.*]], label [[BAD:%.*]]
+; CHECK-NEXT:    br i1 [[C:%.*]], label [[GOOD:%.*]], label [[BAD:%.*]]
 ; CHECK:       good:
 ; CHECK-NEXT:    ret i32 0
 ; CHECK:       bad:
@@ -606,7 +606,7 @@ define i32 @test11() {
 
 entry:
   %X = alloca i32
-  br i1 undef, label %good, label %bad
+  br i1 %c, label %good, label %bad
 
 good:
   %Y = getelementptr i32, i32* %X, i64 0
@@ -855,7 +855,7 @@ entry:
 
 %opaque = type opaque
 
-define i32 @test19(%opaque* %x) {
+define i64 @test19(%opaque* %x) {
 ; This input will cause us to try to compute a natural GEP when rewriting
 ; pointers in such a way that we try to GEP through the opaque type. Previously,
 ; a check for an unsized type was missing and this crashed. Ensure it behaves
@@ -866,7 +866,7 @@ define i32 @test19(%opaque* %x) {
 ; CHECK-NEXT:    [[A_SROA_0_0_COPYLOAD:%.*]] = load i64, ptr [[CAST1]], align 1
 ; CHECK-NEXT:    [[A_SROA_2_0_CAST1_SROA_IDX:%.*]] = getelementptr inbounds i8, ptr [[CAST1]], i64 8
 ; CHECK-NEXT:    [[A_SROA_2_0_COPYLOAD:%.*]] = load ptr, ptr [[A_SROA_2_0_CAST1_SROA_IDX]], align 1
-; CHECK-NEXT:    ret i32 undef
+; CHECK-NEXT:    ret i64 [[A_SROA_0_0_COPYLOAD]]
 ;
 
 entry:
@@ -876,12 +876,12 @@ entry:
   call void @llvm.memcpy.p0i8.p0i8.i32(i8* %cast2, i8* %cast1, i32 16, i1 false)
   %gep = getelementptr inbounds { i64, i8* }, { i64, i8* }* %a, i32 0, i32 0
   %val = load i64, i64* %gep
-  ret i32 undef
+  ret i64 %val
 }
 
 declare void @llvm.memcpy.p0i8.p1i8.i32(i8* nocapture, i8 addrspace(1)* nocapture, i32, i32, i1) nounwind
 
-define i32 @test19_addrspacecast(%opaque* %x) {
+define i64 @test19_addrspacecast(%opaque* %x) {
 ; This input will cause us to try to compute a natural GEP when rewriting
 ; pointers in such a way that we try to GEP through the opaque type. Previously,
 ; a check for an unsized type was missing and this crashed. Ensure it behaves
@@ -892,7 +892,7 @@ define i32 @test19_addrspacecast(%opaque* %x) {
 ; CHECK-NEXT:    [[A_SROA_0_0_COPYLOAD:%.*]] = load i64, ptr addrspace(1) [[CAST1]], align 1
 ; CHECK-NEXT:    [[A_SROA_2_0_CAST1_SROA_IDX:%.*]] = getelementptr inbounds i8, ptr addrspace(1) [[CAST1]], i16 8
 ; CHECK-NEXT:    [[A_SROA_2_0_COPYLOAD:%.*]] = load ptr, ptr addrspace(1) [[A_SROA_2_0_CAST1_SROA_IDX]], align 1
-; CHECK-NEXT:    ret i32 undef
+; CHECK-NEXT:    ret i64 [[A_SROA_0_0_COPYLOAD]]
 ;
 
 entry:
@@ -902,7 +902,7 @@ entry:
   call void @llvm.memcpy.p0i8.p1i8.i32(i8* %cast2, i8 addrspace(1)* %cast1, i32 16, i32 1, i1 false)
   %gep = getelementptr inbounds { i64, i8* }, { i64, i8* }* %a, i32 0, i32 0
   %val = load i64, i64* %gep
-  ret i32 undef
+  ret i64 %val
 }
 
 define i32 @test20() {
@@ -983,13 +983,13 @@ entry:
   ret void
 }
 
-define void @PR13916.2() {
+define void @PR13916.2(i1 %c) {
 ; Check whether we continue to handle them correctly when they start off with
 ; 
diff erent pointer value chains, but during rewriting we coalesce them into the
 ; same value.
 ; CHECK-LABEL: @PR13916.2(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 undef, label [[IF_THEN:%.*]], label [[IF_END:%.*]]
+; CHECK-NEXT:    br i1 [[C:%.*]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
 ; CHECK:       if.then:
 ; CHECK-NEXT:    br label [[IF_END]]
 ; CHECK:       if.end:
@@ -998,7 +998,7 @@ define void @PR13916.2() {
 
 entry:
   %a = alloca %PR13916.struct, align 1
-  br i1 undef, label %if.then, label %if.end
+  br i1 %c, label %if.then, label %if.end
 
 if.then:
   %tmp0 = bitcast %PR13916.struct* %a to i8*
@@ -1012,41 +1012,41 @@ if.end:
   ret void
 }
 
-define void @PR13990() {
+define void @PR13990(i1 %c1, i1 %c2, i1 %c3, i1 %c4, i8* %ptr) {
 ; Ensure we can handle cases where processing one alloca causes the other
 ; alloca to become dead and get deleted. This might crash or fail under
 ; Valgrind if we regress.
 ; CHECK-LABEL: @PR13990(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK-NEXT:    br i1 [[C1:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
 ; CHECK:       bb1:
-; CHECK-NEXT:    br i1 undef, label [[BB2]], label [[BB3:%.*]]
+; CHECK-NEXT:    br i1 [[C2:%.*]], label [[BB2]], label [[BB3:%.*]]
 ; CHECK:       bb2:
-; CHECK-NEXT:    br i1 undef, label [[BB3]], label [[BB4:%.*]]
+; CHECK-NEXT:    br i1 [[C4:%.*]], label [[BB3]], label [[BB4:%.*]]
 ; CHECK:       bb3:
-; CHECK-NEXT:    unreachable
+; CHECK-NEXT:    ret void
 ; CHECK:       bb4:
-; CHECK-NEXT:    unreachable
+; CHECK-NEXT:    ret void
 ;
 
 entry:
   %tmp1 = alloca i8*
   %tmp2 = alloca i8*
-  br i1 undef, label %bb1, label %bb2
+  br i1 %c1, label %bb1, label %bb2
 
 bb1:
-  store i8* undef, i8** %tmp2
-  br i1 undef, label %bb2, label %bb3
+  store i8* %ptr, i8** %tmp2
+  br i1 %c2, label %bb2, label %bb3
 
 bb2:
-  %tmp50 = select i1 undef, i8** %tmp2, i8** %tmp1
-  br i1 undef, label %bb3, label %bb4
+  %tmp50 = select i1 %c3, i8** %tmp2, i8** %tmp1
+  br i1 %c4, label %bb3, label %bb4
 
 bb3:
-  unreachable
+  ret void
 
 bb4:
-  unreachable
+  ret void
 }
 
 define double @PR13969(double %x) {
@@ -1075,14 +1075,14 @@ entry:
 %PR14034.struct = type { { {} }, i32, %PR14034.list }
 %PR14034.list = type { %PR14034.list*, %PR14034.list* }
 
-define void @PR14034() {
+define void @PR14034(%PR14034.list* %ptr, %PR14034.struct* %ptr2) {
 ; This test case tries to form GEPs into the empty leading struct members, and
 ; subsequently crashed (under valgrind) before we fixed the PR. The important
 ; thing is to handle empty structs gracefully.
 ; CHECK-LABEL: @PR14034(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[A_SROA_0:%.*]] = alloca [12 x i8], align 8
-; CHECK-NEXT:    [[CAST0:%.*]] = bitcast ptr undef to ptr
+; CHECK-NEXT:    [[CAST0:%.*]] = bitcast ptr [[PTR2:%.*]] to ptr
 ; CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i32(ptr align 1 [[CAST0]], ptr align 8 [[A_SROA_0]], i32 12, i1 false)
 ; CHECK-NEXT:    ret void
 ;
@@ -1091,8 +1091,8 @@ entry:
   %a = alloca %PR14034.struct
   %list = getelementptr %PR14034.struct, %PR14034.struct* %a, i32 0, i32 2
   %prev = getelementptr %PR14034.list, %PR14034.list* %list, i32 0, i32 1
-  store %PR14034.list* undef, %PR14034.list** %prev
-  %cast0 = bitcast %PR14034.struct* undef to i8*
+  store %PR14034.list* %ptr, %PR14034.list** %prev
+  %cast0 = bitcast %PR14034.struct* %ptr2 to i8*
   %cast1 = bitcast %PR14034.struct* %a to i8*
   call void @llvm.memcpy.p0i8.p0i8.i32(i8* %cast0, i8* %cast1, i32 12, i1 false)
   ret void
@@ -1103,17 +1103,17 @@ define i32 @test22(i32 %x) {
 ; types involving wrapper aggregates and zero-length aggregate members.
 ; CHECK-LABEL: @test22(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[WRAP1:%.*]] = insertvalue [1 x { i32 }] undef, i32 [[X:%.*]], 0, 0
+; CHECK-NEXT:    [[WRAP1:%.*]] = insertvalue [1 x { i32 }] poison, i32 [[X:%.*]], 0, 0
 ; CHECK-NEXT:    [[WRAP1_FCA_0_0_EXTRACT:%.*]] = extractvalue [1 x { i32 }] [[WRAP1]], 0, 0
 ; CHECK-NEXT:    [[TMP0:%.*]] = bitcast i32 [[WRAP1_FCA_0_0_EXTRACT]] to float
 ; CHECK-NEXT:    [[LOAD1_FCA_0_0_0_INSERT:%.*]] = insertvalue { [1 x { float }] } poison, float [[TMP0]], 0, 0, 0
 ; CHECK-NEXT:    [[UNWRAP1:%.*]] = extractvalue { [1 x { float }] } [[LOAD1_FCA_0_0_0_INSERT]], 0, 0
-; CHECK-NEXT:    [[WRAP2:%.*]] = insertvalue { {}, { float }, [0 x i8] } undef, { float } [[UNWRAP1]], 1
+; CHECK-NEXT:    [[WRAP2:%.*]] = insertvalue { {}, { float }, [0 x i8] } poison, { float } [[UNWRAP1]], 1
 ; CHECK-NEXT:    [[WRAP2_FCA_1_0_EXTRACT:%.*]] = extractvalue { {}, { float }, [0 x i8] } [[WRAP2]], 1, 0
 ; CHECK-NEXT:    [[TMP1:%.*]] = bitcast float [[WRAP2_FCA_1_0_EXTRACT]] to <4 x i8>
 ; CHECK-NEXT:    [[VALCAST1:%.*]] = bitcast <4 x i8> [[TMP1]] to i32
-; CHECK-NEXT:    [[WRAP3:%.*]] = insertvalue [1 x [1 x i32]] undef, i32 [[VALCAST1]], 0, 0
-; CHECK-NEXT:    [[WRAP4:%.*]] = insertvalue { [1 x [1 x i32]], {} } undef, [1 x [1 x i32]] [[WRAP3]], 0
+; CHECK-NEXT:    [[WRAP3:%.*]] = insertvalue [1 x [1 x i32]] poison, i32 [[VALCAST1]], 0, 0
+; CHECK-NEXT:    [[WRAP4:%.*]] = insertvalue { [1 x [1 x i32]], {} } poison, [1 x [1 x i32]] [[WRAP3]], 0
 ; CHECK-NEXT:    [[WRAP4_FCA_0_0_0_EXTRACT:%.*]] = extractvalue { [1 x [1 x i32]], {} } [[WRAP4]], 0, 0, 0
 ; CHECK-NEXT:    [[TMP2:%.*]] = bitcast i32 [[WRAP4_FCA_0_0_0_EXTRACT]] to <4 x i8>
 ; CHECK-NEXT:    [[TMP3:%.*]] = bitcast <4 x i8> [[TMP2]] to float
@@ -1128,7 +1128,7 @@ entry:
   %a2 = alloca { {}, { float }, [0 x i8] }
   %a3 = alloca { [0 x i8], { [0 x double], [1 x [1 x <4 x i8>]], {} }, { { {} } } }
 
-  %wrap1 = insertvalue [1 x { i32 }] undef, i32 %x, 0, 0
+  %wrap1 = insertvalue [1 x { i32 }] poison, i32 %x, 0, 0
   %gep1 = getelementptr { { [1 x { i32 }] } }, { { [1 x { i32 }] } }* %a1, i32 0, i32 0, i32 0
   store [1 x { i32 }] %wrap1, [1 x { i32 }]* %gep1
 
@@ -1137,7 +1137,7 @@ entry:
   %load1 = load { [1 x { float }] }, { [1 x { float }] }* %ptrcast1
   %unwrap1 = extractvalue { [1 x { float }] } %load1, 0, 0
 
-  %wrap2 = insertvalue { {}, { float }, [0 x i8] } undef, { float } %unwrap1, 1
+  %wrap2 = insertvalue { {}, { float }, [0 x i8] } poison, { float } %unwrap1, 1
   store { {}, { float }, [0 x i8] } %wrap2, { {}, { float }, [0 x i8] }* %a2
 
   %gep3 = getelementptr { {}, { float }, [0 x i8] }, { {}, { float }, [0 x i8] }* %a2, i32 0, i32 1, i32 0
@@ -1145,8 +1145,8 @@ entry:
   %load3 = load <4 x i8>, <4 x i8>* %ptrcast2
   %valcast1 = bitcast <4 x i8> %load3 to i32
 
-  %wrap3 = insertvalue [1 x [1 x i32]] undef, i32 %valcast1, 0, 0
-  %wrap4 = insertvalue { [1 x [1 x i32]], {} } undef, [1 x [1 x i32]] %wrap3, 0
+  %wrap3 = insertvalue [1 x [1 x i32]] poison, i32 %valcast1, 0, 0
+  %wrap4 = insertvalue { [1 x [1 x i32]], {} } poison, [1 x [1 x i32]] %wrap3, 0
   %gep4 = getelementptr { [0 x i8], { [0 x double], [1 x [1 x <4 x i8>]], {} }, { { {} } } }, { [0 x i8], { [0 x double], [1 x [1 x <4 x i8>]], {} }, { { {} } } }* %a3, i32 0, i32 1
   %ptrcast3 = bitcast { [0 x double], [1 x [1 x <4 x i8>]], {} }* %gep4 to { [1 x [1 x i32]], {} }*
   store { [1 x [1 x i32]], {} } %wrap4, { [1 x [1 x i32]], {} }* %ptrcast3
@@ -1531,20 +1531,20 @@ end:
   ret void
 }
 
-define void @PR15805(i1 %a, i1 %b) {
+define i64 @PR15805(i1 %a, i1 %b) {
 ; CHECK-LABEL: @PR15805(
-; CHECK-NEXT:    [[COND_SROA_SPECULATED:%.*]] = select i1 undef, i64 undef, i64 undef
-; CHECK-NEXT:    ret void
+; CHECK-NEXT:    [[COND_SROA_SPECULATED:%.*]] = select i1 [[B:%.*]], i64 undef, i64 undef
+; CHECK-NEXT:    ret i64 [[COND_SROA_SPECULATED]]
 ;
 
   %c = alloca i64, align 8
-  %p.0.c = select i1 undef, i64* %c, i64* %c
-  %cond.in = select i1 undef, i64* %p.0.c, i64* %c
+  %p.0.c = select i1 %a, i64* %c, i64* %c
+  %cond.in = select i1 %b, i64* %p.0.c, i64* %c
   %cond = load i64, i64* %cond.in, align 8
-  ret void
+  ret i64 %cond
 }
 
-define void @PR15805.1(i1 %a, i1 %b) {
+define void @PR15805.1(i1 %a, i1 %b, i1 %c1) {
 ; Same as the normal PR15805, but rigged to place the use before the def inside
 ; of looping unreachable code. This helps ensure that we aren't sensitive to the
 ; order in which the uses of the alloca are visited.
@@ -1552,8 +1552,8 @@ define void @PR15805.1(i1 %a, i1 %b) {
 ; CHECK-LABEL: @PR15805.1(
 ; CHECK-NEXT:    br label [[EXIT:%.*]]
 ; CHECK:       loop:
-; CHECK-NEXT:    [[COND_SROA_SPECULATED:%.*]] = select i1 undef, i64 undef, i64 undef
-; CHECK-NEXT:    br i1 undef, label [[LOOP:%.*]], label [[EXIT]]
+; CHECK-NEXT:    [[COND_SROA_SPECULATED:%.*]] = select i1 [[A:%.*]], i64 undef, i64 undef
+; CHECK-NEXT:    br i1 [[C1:%.*]], label [[LOOP:%.*]], label [[EXIT]]
 ; CHECK:       exit:
 ; CHECK-NEXT:    ret void
 ;
@@ -1562,16 +1562,16 @@ define void @PR15805.1(i1 %a, i1 %b) {
   br label %exit
 
 loop:
-  %cond.in = select i1 undef, i64* %c, i64* %p.0.c
-  %p.0.c = select i1 undef, i64* %c, i64* %c
+  %cond.in = select i1 %a, i64* %c, i64* %p.0.c
+  %p.0.c = select i1 %b, i64* %c, i64* %c
   %cond = load i64, i64* %cond.in, align 8
-  br i1 undef, label %loop, label %exit
+  br i1 %c1, label %loop, label %exit
 
 exit:
   ret void
 }
 
-define void @PR16651.1(i8* %a) {
+define i8 @PR16651.1(i8* %a) {
 ; This test case caused a crash due to the volatile memcpy in combination with
 ; lowering to integer loads and stores of a width other than that of the original
 ; memcpy.
@@ -1589,8 +1589,8 @@ define void @PR16651.1(i8* %a) {
 ; CHECK-NEXT:    [[B_SROA_2_0_A_SROA_IDX:%.*]] = getelementptr inbounds i8, ptr [[A]], i64 3
 ; CHECK-NEXT:    [[B_SROA_2_0_COPYLOAD:%.*]] = load volatile i8, ptr [[B_SROA_2_0_A_SROA_IDX]], align 1
 ; CHECK-NEXT:    store volatile i8 [[B_SROA_2_0_COPYLOAD]], ptr [[B_SROA_2]], align 1
-; CHECK-NEXT:    [[B_SROA_1_0_B_SROA_1_2_:%.*]] = load i8, ptr [[B_SROA_1]], align 2
-; CHECK-NEXT:    unreachable
+; CHECK-NEXT:    [[B_SROA_1_0_B_SROA_1_2_V:%.*]] = load i8, ptr [[B_SROA_1]], align 2
+; CHECK-NEXT:    ret i8 [[B_SROA_1_0_B_SROA_1_2_V]]
 ;
 
 entry:
@@ -1598,11 +1598,11 @@ entry:
   %b.cast = bitcast i32* %b to i8*
   call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %b.cast, i8* align 4 %a, i32 4, i1 true)
   %b.gep = getelementptr inbounds i8, i8* %b.cast, i32 2
-  load i8, i8* %b.gep, align 2
-  unreachable
+  %v = load i8, i8* %b.gep, align 2
+  ret i8 %v
 }
 
-define void @PR16651.2() {
+define float @PR16651.2(<2 x float> %val, i1 %c1) {
 ; This test case caused a crash due to failing to promote given a select that
 ; can't be speculated. It shouldn't be promoted, but we missed that fact when
 ; analyzing whether we could form a vector promotion because that code didn't
@@ -1611,20 +1611,20 @@ define void @PR16651.2() {
 ; CHECK-LABEL: @PR16651.2(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[TV1_SROA_0:%.*]] = alloca <2 x float>, align 8
-; CHECK-NEXT:    store <2 x float> undef, ptr [[TV1_SROA_0]], align 8
-; CHECK-NEXT:    [[COND105_IN_I_I:%.*]] = select i1 undef, ptr null, ptr [[TV1_SROA_0]]
+; CHECK-NEXT:    store <2 x float> [[VAL:%.*]], ptr [[TV1_SROA_0]], align 8
+; CHECK-NEXT:    [[COND105_IN_I_I:%.*]] = select i1 [[C1:%.*]], ptr null, ptr [[TV1_SROA_0]]
 ; CHECK-NEXT:    [[COND105_I_I:%.*]] = load float, ptr [[COND105_IN_I_I]], align 8
-; CHECK-NEXT:    ret void
+; CHECK-NEXT:    ret float [[COND105_I_I]]
 ;
 
 entry:
   %tv1 = alloca { <2 x float>, <2 x float> }, align 8
   %0 = getelementptr { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %tv1, i64 0, i32 1
-  store <2 x float> undef, <2 x float>* %0, align 8
+  store <2 x float> %val, <2 x float>* %0, align 8
   %1 = getelementptr inbounds { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %tv1, i64 0, i32 1, i64 0
-  %cond105.in.i.i = select i1 undef, float* null, float* %1
+  %cond105.in.i.i = select i1 %c1, float* null, float* %1
   %cond105.i.i = load float, float* %cond105.in.i.i, align 8
-  ret void
+  ret float %cond105.i.i
 }
 
 define void @test23(i32 %x) {
@@ -1643,7 +1643,7 @@ entry:
   ret void
 }
 
-define void @PR18615() {
+define void @PR18615(i8* %ptr) {
 ; CHECK-LABEL: @PR18615(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    ret void
@@ -1651,7 +1651,7 @@ define void @PR18615() {
 entry:
   %f = alloca i8
   %gep = getelementptr i8, i8* %f, i64 -1
-  call void @llvm.memcpy.p0i8.p0i8.i32(i8* undef, i8* %gep, i32 1, i1 false)
+  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %ptr, i8* %gep, i32 1, i1 false)
   ret void
 }
 
@@ -2025,7 +2025,7 @@ entry:
 
 declare void @llvm.lifetime.start.isVoid.i64.p0i8(i64, [10 x float]* nocapture)
 declare void @llvm.lifetime.end.isVoid.i64.p0i8(i64, [10 x float]* nocapture)
- at array = dso_local global [10 x float] undef, align 4
+ at array = dso_local global [10 x float] zeroinitializer, align 4
 
 define void @test29(i32 %num, i32 %tid) {
 ; CHECK-LABEL: @test29(

diff  --git a/llvm/test/Transforms/SROA/basictest.ll b/llvm/test/Transforms/SROA/basictest.ll
index 66443c1715332..82221b49c5f0f 100644
--- a/llvm/test/Transforms/SROA/basictest.ll
+++ b/llvm/test/Transforms/SROA/basictest.ll
@@ -580,7 +580,7 @@ define %S2 @test8(%S2* %arg) {
 ; CHECK-NEXT:    [[S2_NEXT_S1:%.*]] = load %S1*, %S1** [[S2_NEXT_S1_PTR]], align 8, !tbaa [[TBAA3]]
 ; CHECK-NEXT:    [[S2_NEXT_NEXT_PTR:%.*]] = getelementptr [[S2]], %S2* [[S2_NEXT]], i64 0, i32 1
 ; CHECK-NEXT:    [[S2_NEXT_NEXT:%.*]] = load %S2*, %S2** [[S2_NEXT_NEXT_PTR]], align 8, !tbaa [[TBAA7]]
-; CHECK-NEXT:    [[RESULT1:%.*]] = insertvalue [[S2]] undef, %S1* [[S2_NEXT_S1]], 0
+; CHECK-NEXT:    [[RESULT1:%.*]] = insertvalue [[S2]] poison, %S1* [[S2_NEXT_S1]], 0
 ; CHECK-NEXT:    [[RESULT2:%.*]] = insertvalue [[S2]] [[RESULT1]], %S2* [[S2_NEXT_NEXT]], 1
 ; CHECK-NEXT:    ret [[S2]] [[RESULT2]]
 ;
@@ -600,7 +600,7 @@ entry:
   store %S2* %s2.next.next, %S2** %new.next.ptr, !tbaa !9
 
   %new.s1 = load %S1*, %S1** %new.s1.ptr
-  %result1 = insertvalue %S2 undef, %S1* %new.s1, 0
+  %result1 = insertvalue %S2 poison, %S1* %new.s1, 0
   %new.next = load %S2*, %S2** %new.next.ptr
   %result2 = insertvalue %S2 %result1, %S2* %new.next, 1
   ret %S2 %result2
@@ -659,10 +659,10 @@ entry:
   ret %S2* %s2ptr
 }
 
-define i32 @test11() {
+define i32 @test11(i1 %c1) {
 ; CHECK-LABEL: @test11(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 undef, label [[GOOD:%.*]], label [[BAD:%.*]]
+; CHECK-NEXT:    br i1 [[C1:%.*]], label [[GOOD:%.*]], label [[BAD:%.*]]
 ; CHECK:       good:
 ; CHECK-NEXT:    ret i32 0
 ; CHECK:       bad:
@@ -671,7 +671,7 @@ define i32 @test11() {
 
 entry:
   %X = alloca i32
-  br i1 undef, label %good, label %bad
+  br i1 %c1, label %good, label %bad
 
 good:
   %Y = getelementptr i32, i32* %X, i64 0
@@ -929,7 +929,7 @@ entry:
 
 %opaque = type opaque
 
-define i32 @test19(%opaque* %x) {
+define i64 @test19(%opaque* %x) {
 ; This input will cause us to try to compute a natural GEP when rewriting
 ; pointers in such a way that we try to GEP through the opaque type. Previously,
 ; a check for an unsized type was missing and this crashed. Ensure it behaves
@@ -942,7 +942,7 @@ define i32 @test19(%opaque* %x) {
 ; CHECK-NEXT:    [[A_SROA_2_0_CAST1_SROA_IDX:%.*]] = getelementptr inbounds i8, i8* [[CAST1]], i64 8
 ; CHECK-NEXT:    [[A_SROA_2_0_CAST1_SROA_CAST:%.*]] = bitcast i8* [[A_SROA_2_0_CAST1_SROA_IDX]] to i8**
 ; CHECK-NEXT:    [[A_SROA_2_0_COPYLOAD:%.*]] = load i8*, i8** [[A_SROA_2_0_CAST1_SROA_CAST]], align 1
-; CHECK-NEXT:    ret i32 undef
+; CHECK-NEXT:    ret i64 [[A_SROA_0_0_COPYLOAD]]
 ;
 
 entry:
@@ -952,12 +952,12 @@ entry:
   call void @llvm.memcpy.p0i8.p0i8.i32(i8* %cast2, i8* %cast1, i32 16, i1 false)
   %gep = getelementptr inbounds { i64, i8* }, { i64, i8* }* %a, i32 0, i32 0
   %val = load i64, i64* %gep
-  ret i32 undef
+  ret i64 %val
 }
 
 declare void @llvm.memcpy.p0i8.p1i8.i32(i8* nocapture, i8 addrspace(1)* nocapture, i32, i32, i1) nounwind
 
-define i32 @test19_addrspacecast(%opaque* %x) {
+define i64 @test19_addrspacecast(%opaque* %x) {
 ; This input will cause us to try to compute a natural GEP when rewriting
 ; pointers in such a way that we try to GEP through the opaque type. Previously,
 ; a check for an unsized type was missing and this crashed. Ensure it behaves
@@ -970,7 +970,7 @@ define i32 @test19_addrspacecast(%opaque* %x) {
 ; CHECK-NEXT:    [[A_SROA_2_0_CAST1_SROA_IDX:%.*]] = getelementptr inbounds i8, i8 addrspace(1)* [[CAST1]], i16 8
 ; CHECK-NEXT:    [[A_SROA_2_0_CAST1_SROA_CAST:%.*]] = bitcast i8 addrspace(1)* [[A_SROA_2_0_CAST1_SROA_IDX]] to i8* addrspace(1)*
 ; CHECK-NEXT:    [[A_SROA_2_0_COPYLOAD:%.*]] = load i8*, i8* addrspace(1)* [[A_SROA_2_0_CAST1_SROA_CAST]], align 1
-; CHECK-NEXT:    ret i32 undef
+; CHECK-NEXT:    ret i64 [[A_SROA_0_0_COPYLOAD]]
 ;
 
 entry:
@@ -980,7 +980,7 @@ entry:
   call void @llvm.memcpy.p0i8.p1i8.i32(i8* %cast2, i8 addrspace(1)* %cast1, i32 16, i32 1, i1 false)
   %gep = getelementptr inbounds { i64, i8* }, { i64, i8* }* %a, i32 0, i32 0
   %val = load i64, i64* %gep
-  ret i32 undef
+  ret i64 %val
 }
 
 define i32 @test20() {
@@ -1061,13 +1061,13 @@ entry:
   ret void
 }
 
-define void @PR13916.2() {
+define void @PR13916.2(i1 %c1) {
 ; Check whether we continue to handle them correctly when they start off with
 ; 
diff erent pointer value chains, but during rewriting we coalesce them into the
 ; same value.
 ; CHECK-LABEL: @PR13916.2(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 undef, label [[IF_THEN:%.*]], label [[IF_END:%.*]]
+; CHECK-NEXT:    br i1 [[C1:%.*]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
 ; CHECK:       if.then:
 ; CHECK-NEXT:    br label [[IF_END]]
 ; CHECK:       if.end:
@@ -1076,7 +1076,7 @@ define void @PR13916.2() {
 
 entry:
   %a = alloca %PR13916.struct, align 1
-  br i1 undef, label %if.then, label %if.end
+  br i1 %c1, label %if.then, label %if.end
 
 if.then:
   %tmp0 = bitcast %PR13916.struct* %a to i8*
@@ -1090,17 +1090,17 @@ if.end:
   ret void
 }
 
-define void @PR13990() {
+define void @PR13990(i1 %c1, i1 %c2, i1 %c3, i1 %c4, i8* %ptr) {
 ; Ensure we can handle cases where processing one alloca causes the other
 ; alloca to become dead and get deleted. This might crash or fail under
 ; Valgrind if we regress.
 ; CHECK-LABEL: @PR13990(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK-NEXT:    br i1 [[C1:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
 ; CHECK:       bb1:
-; CHECK-NEXT:    br i1 undef, label [[BB2]], label [[BB3:%.*]]
+; CHECK-NEXT:    br i1 [[C2:%.*]], label [[BB2]], label [[BB3:%.*]]
 ; CHECK:       bb2:
-; CHECK-NEXT:    br i1 undef, label [[BB3]], label [[BB4:%.*]]
+; CHECK-NEXT:    br i1 [[C4:%.*]], label [[BB3]], label [[BB4:%.*]]
 ; CHECK:       bb3:
 ; CHECK-NEXT:    unreachable
 ; CHECK:       bb4:
@@ -1110,15 +1110,15 @@ define void @PR13990() {
 entry:
   %tmp1 = alloca i8*
   %tmp2 = alloca i8*
-  br i1 undef, label %bb1, label %bb2
+  br i1 %c1, label %bb1, label %bb2
 
 bb1:
-  store i8* undef, i8** %tmp2
-  br i1 undef, label %bb2, label %bb3
+  store i8* %ptr, i8** %tmp2
+  br i1 %c2, label %bb2, label %bb3
 
 bb2:
-  %tmp50 = select i1 undef, i8** %tmp2, i8** %tmp1
-  br i1 undef, label %bb3, label %bb4
+  %tmp50 = select i1 %c3, i8** %tmp2, i8** %tmp1
+  br i1 %c4, label %bb3, label %bb4
 
 bb3:
   unreachable
@@ -1153,15 +1153,16 @@ entry:
 %PR14034.struct = type { { {} }, i32, %PR14034.list }
 %PR14034.list = type { %PR14034.list*, %PR14034.list* }
 
-define void @PR14034() {
+define void @PR14034(%PR14034.list* %ptr, %PR14034.struct* %ptr2) {
 ; This test case tries to form GEPs into the empty leading struct members, and
 ; subsequently crashed (under valgrind) before we fixed the PR. The important
 ; thing is to handle empty structs gracefully.
 ; CHECK-LABEL: @PR14034(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[A_SROA_0:%.*]] = alloca [12 x i8], align 8
+; CHECK-NEXT:    [[A_SROA_0_0_CAST0_SROA_CAST:%.*]] = bitcast %PR14034.struct* [[PTR2:%.*]] to i8*
 ; CHECK-NEXT:    [[A_SROA_0_0_CAST1_SROA_IDX:%.*]] = getelementptr inbounds [12 x i8], [12 x i8]* [[A_SROA_0]], i64 0, i64 0
-; CHECK-NEXT:    call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 undef, i8* align 8 [[A_SROA_0_0_CAST1_SROA_IDX]], i32 12, i1 false)
+; CHECK-NEXT:    call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 [[A_SROA_0_0_CAST0_SROA_CAST]], i8* align 8 [[A_SROA_0_0_CAST1_SROA_IDX]], i32 12, i1 false)
 ; CHECK-NEXT:    ret void
 ;
 
@@ -1169,8 +1170,8 @@ entry:
   %a = alloca %PR14034.struct
   %list = getelementptr %PR14034.struct, %PR14034.struct* %a, i32 0, i32 2
   %prev = getelementptr %PR14034.list, %PR14034.list* %list, i32 0, i32 1
-  store %PR14034.list* undef, %PR14034.list** %prev
-  %cast0 = bitcast %PR14034.struct* undef to i8*
+  store %PR14034.list* %ptr, %PR14034.list** %prev
+  %cast0 = bitcast %PR14034.struct* %ptr2 to i8*
   %cast1 = bitcast %PR14034.struct* %a to i8*
   call void @llvm.memcpy.p0i8.p0i8.i32(i8* %cast0, i8* %cast1, i32 12, i1 false)
   ret void
@@ -1181,17 +1182,17 @@ define i32 @test22(i32 %x) {
 ; types involving wrapper aggregates and zero-length aggregate members.
 ; CHECK-LABEL: @test22(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[WRAP1:%.*]] = insertvalue [1 x { i32 }] undef, i32 [[X:%.*]], 0, 0
+; CHECK-NEXT:    [[WRAP1:%.*]] = insertvalue [1 x { i32 }] poison, i32 [[X:%.*]], 0, 0
 ; CHECK-NEXT:    [[WRAP1_FCA_0_0_EXTRACT:%.*]] = extractvalue [1 x { i32 }] [[WRAP1]], 0, 0
 ; CHECK-NEXT:    [[TMP0:%.*]] = bitcast i32 [[WRAP1_FCA_0_0_EXTRACT]] to float
 ; CHECK-NEXT:    [[LOAD1_FCA_0_0_0_INSERT:%.*]] = insertvalue { [1 x { float }] } poison, float [[TMP0]], 0, 0, 0
 ; CHECK-NEXT:    [[UNWRAP1:%.*]] = extractvalue { [1 x { float }] } [[LOAD1_FCA_0_0_0_INSERT]], 0, 0
-; CHECK-NEXT:    [[WRAP2:%.*]] = insertvalue { {}, { float }, [0 x i8] } undef, { float } [[UNWRAP1]], 1
+; CHECK-NEXT:    [[WRAP2:%.*]] = insertvalue { {}, { float }, [0 x i8] } poison, { float } [[UNWRAP1]], 1
 ; CHECK-NEXT:    [[WRAP2_FCA_1_0_EXTRACT:%.*]] = extractvalue { {}, { float }, [0 x i8] } [[WRAP2]], 1, 0
 ; CHECK-NEXT:    [[TMP1:%.*]] = bitcast float [[WRAP2_FCA_1_0_EXTRACT]] to <4 x i8>
 ; CHECK-NEXT:    [[VALCAST1:%.*]] = bitcast <4 x i8> [[TMP1]] to i32
-; CHECK-NEXT:    [[WRAP3:%.*]] = insertvalue [1 x [1 x i32]] undef, i32 [[VALCAST1]], 0, 0
-; CHECK-NEXT:    [[WRAP4:%.*]] = insertvalue { [1 x [1 x i32]], {} } undef, [1 x [1 x i32]] [[WRAP3]], 0
+; CHECK-NEXT:    [[WRAP3:%.*]] = insertvalue [1 x [1 x i32]] poison, i32 [[VALCAST1]], 0, 0
+; CHECK-NEXT:    [[WRAP4:%.*]] = insertvalue { [1 x [1 x i32]], {} } poison, [1 x [1 x i32]] [[WRAP3]], 0
 ; CHECK-NEXT:    [[WRAP4_FCA_0_0_0_EXTRACT:%.*]] = extractvalue { [1 x [1 x i32]], {} } [[WRAP4]], 0, 0, 0
 ; CHECK-NEXT:    [[TMP2:%.*]] = bitcast i32 [[WRAP4_FCA_0_0_0_EXTRACT]] to <4 x i8>
 ; CHECK-NEXT:    [[TMP3:%.*]] = bitcast <4 x i8> [[TMP2]] to float
@@ -1206,7 +1207,7 @@ entry:
   %a2 = alloca { {}, { float }, [0 x i8] }
   %a3 = alloca { [0 x i8], { [0 x double], [1 x [1 x <4 x i8>]], {} }, { { {} } } }
 
-  %wrap1 = insertvalue [1 x { i32 }] undef, i32 %x, 0, 0
+  %wrap1 = insertvalue [1 x { i32 }] poison, i32 %x, 0, 0
   %gep1 = getelementptr { { [1 x { i32 }] } }, { { [1 x { i32 }] } }* %a1, i32 0, i32 0, i32 0
   store [1 x { i32 }] %wrap1, [1 x { i32 }]* %gep1
 
@@ -1215,7 +1216,7 @@ entry:
   %load1 = load { [1 x { float }] }, { [1 x { float }] }* %ptrcast1
   %unwrap1 = extractvalue { [1 x { float }] } %load1, 0, 0
 
-  %wrap2 = insertvalue { {}, { float }, [0 x i8] } undef, { float } %unwrap1, 1
+  %wrap2 = insertvalue { {}, { float }, [0 x i8] } poison, { float } %unwrap1, 1
   store { {}, { float }, [0 x i8] } %wrap2, { {}, { float }, [0 x i8] }* %a2
 
   %gep3 = getelementptr { {}, { float }, [0 x i8] }, { {}, { float }, [0 x i8] }* %a2, i32 0, i32 1, i32 0
@@ -1223,8 +1224,8 @@ entry:
   %load3 = load <4 x i8>, <4 x i8>* %ptrcast2
   %valcast1 = bitcast <4 x i8> %load3 to i32
 
-  %wrap3 = insertvalue [1 x [1 x i32]] undef, i32 %valcast1, 0, 0
-  %wrap4 = insertvalue { [1 x [1 x i32]], {} } undef, [1 x [1 x i32]] %wrap3, 0
+  %wrap3 = insertvalue [1 x [1 x i32]] poison, i32 %valcast1, 0, 0
+  %wrap4 = insertvalue { [1 x [1 x i32]], {} } poison, [1 x [1 x i32]] %wrap3, 0
   %gep4 = getelementptr { [0 x i8], { [0 x double], [1 x [1 x <4 x i8>]], {} }, { { {} } } }, { [0 x i8], { [0 x double], [1 x [1 x <4 x i8>]], {} }, { { {} } } }* %a3, i32 0, i32 1
   %ptrcast3 = bitcast { [0 x double], [1 x [1 x <4 x i8>]], {} }* %gep4 to { [1 x [1 x i32]], {} }*
   store { [1 x [1 x i32]], {} } %wrap4, { [1 x [1 x i32]], {} }* %ptrcast3
@@ -1620,18 +1621,18 @@ end:
 
 define void @PR15805(i1 %a, i1 %b) {
 ; CHECK-LABEL: @PR15805(
-; CHECK-NEXT:    [[COND_SROA_SPECULATED:%.*]] = select i1 undef, i64 undef, i64 undef
+; CHECK-NEXT:    [[COND_SROA_SPECULATED:%.*]] = select i1 [[B:%.*]], i64 undef, i64 undef
 ; CHECK-NEXT:    ret void
 ;
 
   %c = alloca i64, align 8
-  %p.0.c = select i1 undef, i64* %c, i64* %c
-  %cond.in = select i1 undef, i64* %p.0.c, i64* %c
+  %p.0.c = select i1 %a, i64* %c, i64* %c
+  %cond.in = select i1 %b, i64* %p.0.c, i64* %c
   %cond = load i64, i64* %cond.in, align 8
   ret void
 }
 
-define void @PR15805.1(i1 %a, i1 %b) {
+define void @PR15805.1(i1 %a, i1 %b, i1 %c2) {
 ; Same as the normal PR15805, but rigged to place the use before the def inside
 ; of looping unreachable code. This helps ensure that we aren't sensitive to the
 ; order in which the uses of the alloca are visited.
@@ -1639,8 +1640,8 @@ define void @PR15805.1(i1 %a, i1 %b) {
 ; CHECK-LABEL: @PR15805.1(
 ; CHECK-NEXT:    br label [[EXIT:%.*]]
 ; CHECK:       loop:
-; CHECK-NEXT:    [[COND_SROA_SPECULATED:%.*]] = select i1 undef, i64 undef, i64 undef
-; CHECK-NEXT:    br i1 undef, label [[LOOP:%.*]], label [[EXIT]]
+; CHECK-NEXT:    [[COND_SROA_SPECULATED:%.*]] = select i1 [[A:%.*]], i64 undef, i64 undef
+; CHECK-NEXT:    br i1 [[C2:%.*]], label [[LOOP:%.*]], label [[EXIT]]
 ; CHECK:       exit:
 ; CHECK-NEXT:    ret void
 ;
@@ -1649,10 +1650,10 @@ define void @PR15805.1(i1 %a, i1 %b) {
   br label %exit
 
 loop:
-  %cond.in = select i1 undef, i64* %c, i64* %p.0.c
-  %p.0.c = select i1 undef, i64* %c, i64* %c
+  %cond.in = select i1 %a, i64* %c, i64* %p.0.c
+  %p.0.c = select i1 %b, i64* %c, i64* %c
   %cond = load i64, i64* %cond.in, align 8
-  br i1 undef, label %loop, label %exit
+  br i1 %c2, label %loop, label %exit
 
 exit:
   ret void
@@ -1690,7 +1691,7 @@ entry:
   unreachable
 }
 
-define void @PR16651.2() {
+define void @PR16651.2(<2 x float> %val, i1 %c1) {
 ; This test case caused a crash due to failing to promote given a select that
 ; can't be speculated. It shouldn't be promoted, but we missed that fact when
 ; analyzing whether we could form a vector promotion because that code didn't
@@ -1699,9 +1700,9 @@ define void @PR16651.2() {
 ; CHECK-LABEL: @PR16651.2(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[TV1_SROA_0:%.*]] = alloca <2 x float>, align 8
-; CHECK-NEXT:    store <2 x float> undef, <2 x float>* [[TV1_SROA_0]], align 8
+; CHECK-NEXT:    store <2 x float> [[VAL:%.*]], <2 x float>* [[TV1_SROA_0]], align 8
 ; CHECK-NEXT:    [[TV1_SROA_0_0__SROA_IDX:%.*]] = getelementptr inbounds <2 x float>, <2 x float>* [[TV1_SROA_0]], i64 0, i32 0
-; CHECK-NEXT:    [[COND105_IN_I_I:%.*]] = select i1 undef, float* null, float* [[TV1_SROA_0_0__SROA_IDX]]
+; CHECK-NEXT:    [[COND105_IN_I_I:%.*]] = select i1 [[C1:%.*]], float* null, float* [[TV1_SROA_0_0__SROA_IDX]]
 ; CHECK-NEXT:    [[COND105_I_I:%.*]] = load float, float* [[COND105_IN_I_I]], align 8
 ; CHECK-NEXT:    ret void
 ;
@@ -1709,9 +1710,9 @@ define void @PR16651.2() {
 entry:
   %tv1 = alloca { <2 x float>, <2 x float> }, align 8
   %0 = getelementptr { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %tv1, i64 0, i32 1
-  store <2 x float> undef, <2 x float>* %0, align 8
+  store <2 x float> %val, <2 x float>* %0, align 8
   %1 = getelementptr inbounds { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* %tv1, i64 0, i32 1, i64 0
-  %cond105.in.i.i = select i1 undef, float* null, float* %1
+  %cond105.in.i.i = select i1 %c1, float* null, float* %1
   %cond105.i.i = load float, float* %cond105.in.i.i, align 8
   ret void
 }
@@ -1732,7 +1733,7 @@ entry:
   ret void
 }
 
-define void @PR18615() {
+define void @PR18615(i8* %ptr) {
 ; CHECK-LABEL: @PR18615(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    ret void
@@ -1740,7 +1741,7 @@ define void @PR18615() {
 entry:
   %f = alloca i8
   %gep = getelementptr i8, i8* %f, i64 -1
-  call void @llvm.memcpy.p0i8.p0i8.i32(i8* undef, i8* %gep, i32 1, i1 false)
+  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %ptr, i8* %gep, i32 1, i1 false)
   ret void
 }
 
@@ -2118,7 +2119,7 @@ entry:
 
 declare void @llvm.lifetime.start.isVoid.i64.p0i8(i64, [10 x float]* nocapture)
 declare void @llvm.lifetime.end.isVoid.i64.p0i8(i64, [10 x float]* nocapture)
- at array = dso_local global [10 x float] undef, align 4
+ at array = dso_local global [10 x float] zeroinitializer, align 4
 
 define void @test29(i32 %num, i32 %tid) {
 ; CHECK-LABEL: @test29(

diff  --git a/llvm/test/Transforms/SROA/dbg-single-piece.ll b/llvm/test/Transforms/SROA/dbg-single-piece.ll
index d9eb41b347725..ba5b609520796 100644
--- a/llvm/test/Transforms/SROA/dbg-single-piece.ll
+++ b/llvm/test/Transforms/SROA/dbg-single-piece.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -passes=sroa %s -S | FileCheck %s
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 
@@ -5,18 +6,20 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 
 declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
 define void @_ZL18findInsertLocationPN4llvm17MachineBasicBlockENS_9SlotIndexERNS_13LiveIntervalsE() {
+; CHECK-LABEL: @_ZL18findInsertLocationPN4llvm17MachineBasicBlockENS_9SlotIndexERNS_13LiveIntervalsE(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    call void @llvm.dbg.value(metadata %foo* poison, metadata [[META3:![0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64)), !dbg [[DBG8:![0-9]+]]
+; CHECK-NEXT:    ret void
+;
 entry:
   %retval = alloca %foo, align 8
   call void @llvm.dbg.declare(metadata %foo* %retval, metadata !1, metadata !7), !dbg !8
 ; Checks that SROA still inserts a bit_piece expression, even if it produces only one piece
 ; (as long as that piece is smaller than the whole thing)
-; CHECK-NOT: call void @llvm.dbg.value
-; CHECK: call void @llvm.dbg.value(metadata %foo* undef, {{.*}}, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64)), !dbg
-; CHECK-NOT: call void @llvm.dbg.value
   %0 = bitcast %foo* %retval to i8*
   %1 = getelementptr inbounds i8, i8* %0, i64 8
   %2 = bitcast i8* %1 to %foo**
-  store %foo* undef, %foo** %2, align 8
+  store %foo* poison, %foo** %2, align 8
   ret void
 }
 

diff  --git a/llvm/test/Transforms/SROA/dead-inst.ll b/llvm/test/Transforms/SROA/dead-inst.ll
index 083c8a6221e1e..7f77f90daeef3 100644
--- a/llvm/test/Transforms/SROA/dead-inst.ll
+++ b/llvm/test/Transforms/SROA/dead-inst.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; SROA fails to rewrite allocs but does rewrite some phis and delete
 ; dead instructions. Ensure that this invalidates analyses required
 ; for other passes.
@@ -17,14 +18,14 @@ target triple = "powerpc64le-grtev4-linux-gnu"
 declare void @D(%class.b* sret(%class.b), %class.b* dereferenceable(32)) local_unnamed_addr
 
 ; Function Attrs: nounwind
-define hidden fastcc void @H(%class.b* noalias nocapture readnone, [2 x i64]) unnamed_addr {
+define void @H(%class.b* noalias nocapture readnone, [2 x i64], i8* %ptr, i32 signext %v, i64 %l, i64 %idx, %class.b* nonnull dereferenceable(32) %ptr2) {
   %3 = alloca %class.b, align 8
   %.sroa.0 = alloca i64, align 8
   store i64 0, i64* %.sroa.0, align 8
   %4 = extractvalue [2 x i64] %1, 1
   switch i64 %4, label %6 [
-    i64 4, label %foo
-    i64 5, label %5
+  i64 4, label %foo
+  i64 5, label %5
   ]
 
 ; <label>:5:
@@ -51,7 +52,7 @@ define hidden fastcc void @H(%class.b* noalias nocapture readnone, [2 x i64]) un
   br i1 %17, label %18, label %a.exit
 
 ; <label>:18:
-  %19 = tail call i8* @memchr(i8* undef, i32 signext undef, i64 undef)
+  %19 = tail call i8* @memchr(i8* %ptr, i32 signext %v, i64 %l)
   %20 = icmp eq i8* %19, null
   %21 = sext i1 %20 to i64
   br label %a.exit
@@ -66,7 +67,7 @@ a.exit:
   br i1 %26, label %G.exit, label %27
 
 ; <label>:27:
-  %28 = getelementptr inbounds i8, i8* %23, i64 undef
+  %28 = getelementptr inbounds i8, i8* %23, i64 %idx
   %29 = icmp eq i8* %28, null
   br i1 %29, label %30, label %31
 
@@ -74,7 +75,7 @@ a.exit:
   unreachable
 
 ; <label>:31:
-  call void @D(%class.b* nonnull sret(%class.b) %3, %class.b* nonnull dereferenceable(32) undef)
+  call void @D(%class.b* nonnull sret(%class.b) %3, %class.b* nonnull dereferenceable(32) %ptr2)
   br label %G.exit
 
 G.exit:

diff  --git a/llvm/test/Transforms/SROA/fca.ll b/llvm/test/Transforms/SROA/fca.ll
index 19be9e79a7cd4..6eaebc3732d44 100644
--- a/llvm/test/Transforms/SROA/fca.ll
+++ b/llvm/test/Transforms/SROA/fca.ll
@@ -1,7 +1,7 @@
 ; RUN: opt < %s -passes=sroa -S | FileCheck %s
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n8:16:32:64"
 
-define { i32, i32 } @test0(i32 %x, i32 %y) {
+define { i32, i32 } @test0(i32 %x, i32 %y, { i32, i32 } %v) {
 ; CHECK-LABEL: @test0(
 ; CHECK-NOT: alloca
 ; CHECK: insertvalue { i32, i32 }
@@ -11,7 +11,7 @@ define { i32, i32 } @test0(i32 %x, i32 %y) {
 entry:
   %a = alloca { i32, i32 }
 
-  store { i32, i32 } undef, { i32, i32 }* %a
+  store { i32, i32 } %v, { i32, i32 }* %a
 
   %gep1 = getelementptr inbounds { i32, i32 }, { i32, i32 }* %a, i32 0, i32 0
   store i32 %x, i32* %gep1

diff  --git a/llvm/test/Transforms/SROA/phi-and-select.ll b/llvm/test/Transforms/SROA/phi-and-select.ll
index 0b74e46d8707f..ab7398df58cf4 100644
--- a/llvm/test/Transforms/SROA/phi-and-select.ll
+++ b/llvm/test/Transforms/SROA/phi-and-select.ll
@@ -265,10 +265,10 @@ entry:
   ret i32 %result
 }
 
-define i32 @test7() {
+define i32 @test7(i1 %c1) {
 ; CHECK-LABEL: @test7(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 undef, label [[GOOD:%.*]], label [[BAD:%.*]]
+; CHECK-NEXT:    br i1 [[C1:%.*]], label [[GOOD:%.*]], label [[BAD:%.*]]
 ; CHECK:       good:
 ; CHECK-NEXT:    br label [[EXIT:%.*]]
 ; CHECK:       bad:
@@ -281,7 +281,7 @@ define i32 @test7() {
 
 entry:
   %X = alloca i32
-  br i1 undef, label %good, label %bad
+  br i1 %c1, label %good, label %bad
 
 good:
   %Y1 = getelementptr i32, i32* %X, i64 0
@@ -422,7 +422,7 @@ entry:
   ret float %loaded
 }
 
-define i32 @test12(i32 %x, i32* %p) {
+define i32 @test12(i32 %x, i32* %p, i1 %c1) {
 ; Ensure we don't crash or fail to nuke dead selects of allocas if no load is
 ; never found.
 ; CHECK-LABEL: @test12(
@@ -433,19 +433,19 @@ define i32 @test12(i32 %x, i32* %p) {
 entry:
   %a = alloca i32
   store i32 %x, i32* %a
-  %dead = select i1 undef, i32* %a, i32* %p
+  %dead = select i1 %c1, i32* %a, i32* %p
   %load = load i32, i32* %a
   ret i32 %load
 }
 
-define i32 @test13(i32 %x, i32* %p) {
+define i32 @test13(i32 %x, i32* %p, i1 %c1) {
 ; Ensure we don't crash or fail to nuke dead phis of allocas if no load is ever
 ; found.
 ; CHECK-LABEL: @test13(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[LOOP:%.*]]
 ; CHECK:       loop:
-; CHECK-NEXT:    br i1 undef, label [[LOOP]], label [[EXIT:%.*]]
+; CHECK-NEXT:    br i1 [[C1:%.*]], label [[LOOP]], label [[EXIT:%.*]]
 ; CHECK:       exit:
 ; CHECK-NEXT:    ret i32 [[X:%.*]]
 ;
@@ -457,7 +457,7 @@ entry:
 
 loop:
   %phi = phi i32* [ %p, %entry ], [ %a, %loop ]
-  br i1 undef, label %loop, label %exit
+  br i1 %c1, label %loop, label %exit
 
 exit:
   %load = load i32, i32* %a
@@ -514,39 +514,39 @@ exit:
   ret i32 %result
 }
 
-define i32 @PR13905() {
+define void @PR13905(i1 %c1, i1 %c2, i1 %c3) {
 ; Check a pattern where we have a chain of dead phi nodes to ensure they are
 ; deleted and promotion can proceed.
 ; CHECK-LABEL: @PR13905(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 undef, label [[LOOP1:%.*]], label [[EXIT:%.*]]
+; CHECK-NEXT:    br i1 [[C1:%.*]], label [[LOOP1:%.*]], label [[EXIT:%.*]]
 ; CHECK:       loop1:
-; CHECK-NEXT:    br i1 undef, label [[LOOP1]], label [[LOOP2:%.*]]
+; CHECK-NEXT:    br i1 [[C2:%.*]], label [[LOOP1]], label [[LOOP2:%.*]]
 ; CHECK:       loop2:
-; CHECK-NEXT:    br i1 undef, label [[LOOP1]], label [[EXIT]]
+; CHECK-NEXT:    br i1 [[C3:%.*]], label [[LOOP1]], label [[EXIT]]
 ; CHECK:       exit:
 ; CHECK-NEXT:    [[PHI2:%.*]] = phi i32* [ poison, [[LOOP2]] ], [ null, [[ENTRY:%.*]] ]
-; CHECK-NEXT:    ret i32 undef
+; CHECK-NEXT:    ret void
 ;
 
 entry:
   %h = alloca i32
   store i32 0, i32* %h
-  br i1 undef, label %loop1, label %exit
+  br i1 %c1, label %loop1, label %exit
 
 loop1:
   %phi1 = phi i32* [ null, %entry ], [ %h, %loop1 ], [ %h, %loop2 ]
-  br i1 undef, label %loop1, label %loop2
+  br i1 %c2, label %loop1, label %loop2
 
 loop2:
-  br i1 undef, label %loop1, label %exit
+  br i1 %c3, label %loop1, label %exit
 
 exit:
   %phi2 = phi i32* [ %phi1, %loop2 ], [ null, %entry ]
-  ret i32 undef
+  ret void
 }
 
-define i32 @PR13906() {
+define i32 @PR13906(i1 %c1, i1 %c2) {
 ; Another pattern which can lead to crashes due to failing to clear out dead
 ; PHI nodes or select nodes. This triggers subtly 
diff erently from the above
 ; cases because the PHI node is (recursively) alive, but the select is dead.
@@ -554,7 +554,7 @@ define i32 @PR13906() {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[FOR_COND:%.*]]
 ; CHECK:       for.cond:
-; CHECK-NEXT:    br i1 undef, label [[IF_THEN:%.*]], label [[FOR_COND]]
+; CHECK-NEXT:    br i1 [[C1:%.*]], label [[IF_THEN:%.*]], label [[FOR_COND]]
 ; CHECK:       if.then:
 ; CHECK-NEXT:    br label [[FOR_COND]]
 ;
@@ -565,11 +565,11 @@ entry:
   br label %for.cond
 
 for.cond:
-  %d.0 = phi i32* [ undef, %entry ], [ %c, %if.then ], [ %d.0, %for.cond ]
-  br i1 undef, label %if.then, label %for.cond
+  %d.0 = phi i32* [ poison, %entry ], [ %c, %if.then ], [ %d.0, %for.cond ]
+  br i1 %c1, label %if.then, label %for.cond
 
 if.then:
-  %tmpcast.d.0 = select i1 undef, i32* %c, i32* %d.0
+  %tmpcast.d.0 = select i1 %c2, i32* %c, i32* %d.0
   br label %for.cond
 }
 
@@ -749,43 +749,43 @@ merge:
 ; when the incoming pointer is itself from a PHI node. We would previously
 ; insert a bitcast instruction *before* a PHI, producing an invalid module;
 ; make sure we insert *after* the first non-PHI instruction.
-define void @PR20822() {
+define void @PR20822(i1 %c1, i1 %c2, %struct.S* %ptr) {
 ; CHECK-LABEL: @PR20822(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[F_SROA_0:%.*]] = alloca i32, align 4
-; CHECK-NEXT:    br i1 undef, label [[IF_END:%.*]], label [[FOR_COND:%.*]]
+; CHECK-NEXT:    br i1 [[C1:%.*]], label [[IF_END:%.*]], label [[FOR_COND:%.*]]
 ; CHECK:       for.cond:
 ; CHECK-NEXT:    br label [[IF_END]]
 ; CHECK:       if.end:
-; CHECK-NEXT:    [[TMP0:%.*]] = phi i32 [ undef, [[ENTRY:%.*]] ], [ undef, [[FOR_COND]] ]
+; CHECK-NEXT:    [[TMP0:%.*]] = phi i32 [ poison, [[ENTRY:%.*]] ], [ poison, [[FOR_COND]] ]
 ; CHECK-NEXT:    [[F_SROA_0_0_F2_SROA_CAST1:%.*]] = bitcast i32* [[F_SROA_0]] to %struct.S*
-; CHECK-NEXT:    br i1 undef, label [[IF_THEN5:%.*]], label [[IF_THEN2:%.*]]
+; CHECK-NEXT:    br i1 [[C2:%.*]], label [[IF_THEN5:%.*]], label [[IF_THEN2:%.*]]
 ; CHECK:       if.then2:
 ; CHECK-NEXT:    br label [[IF_THEN5]]
 ; CHECK:       if.then5:
-; CHECK-NEXT:    [[F1:%.*]] = phi %struct.S* [ undef, [[IF_THEN2]] ], [ [[F_SROA_0_0_F2_SROA_CAST1]], [[IF_END]] ]
+; CHECK-NEXT:    [[F1:%.*]] = phi %struct.S* [ [[PTR:%.*]], [[IF_THEN2]] ], [ [[F_SROA_0_0_F2_SROA_CAST1]], [[IF_END]] ]
 ; CHECK-NEXT:    [[DOTFCA_0_GEP:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], %struct.S* [[F1]], i32 0, i32 0
-; CHECK-NEXT:    store i32 undef, i32* [[DOTFCA_0_GEP]], align 4
+; CHECK-NEXT:    store i32 0, i32* [[DOTFCA_0_GEP]], align 4
 ; CHECK-NEXT:    ret void
 ;
 entry:
   %f = alloca %struct.S, align 4
-  br i1 undef, label %if.end, label %for.cond
+  br i1 %c1, label %if.end, label %for.cond
 
 for.cond:                                         ; preds = %for.cond, %entry
   br label %if.end
 
 if.end:                                           ; preds = %for.cond, %entry
   %f2 = phi %struct.S* [ %f, %entry ], [ %f, %for.cond ]
-  phi i32 [ undef, %entry ], [ undef, %for.cond ]
-  br i1 undef, label %if.then5, label %if.then2
+  phi i32 [ poison, %entry ], [ poison, %for.cond ]
+  br i1 %c2, label %if.then5, label %if.then2
 
 if.then2:                                         ; preds = %if.end
   br label %if.then5
 
 if.then5:                                         ; preds = %if.then2, %if.end
-  %f1 = phi %struct.S* [ undef, %if.then2 ], [ %f2, %if.end ]
-  store %struct.S undef, %struct.S* %f1, align 4
+  %f1 = phi %struct.S* [ %ptr, %if.then2 ], [ %f2, %if.end ]
+  store %struct.S zeroinitializer, %struct.S* %f1, align 4
   ret void
 }
 

diff  --git a/llvm/test/Transforms/SROA/phi-gep.ll b/llvm/test/Transforms/SROA/phi-gep.ll
index ac0038e38af4d..7b3ad1868f723 100644
--- a/llvm/test/Transforms/SROA/phi-gep.ll
+++ b/llvm/test/Transforms/SROA/phi-gep.ll
@@ -61,15 +61,15 @@ end:
   ret i32 %load
 }
 
-define i32 @test_sroa_phi_gep_undef(i1 %cond) {
-; CHECK-LABEL: @test_sroa_phi_gep_undef(
+define i32 @test_sroa_phi_gep_poison(i1 %cond) {
+; CHECK-LABEL: @test_sroa_phi_gep_poison(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[A:%.*]] = alloca [[PAIR:%.*]], align 4
 ; CHECK-NEXT:    br i1 [[COND:%.*]], label [[IF_THEN:%.*]], label [[END:%.*]]
 ; CHECK:       if.then:
 ; CHECK-NEXT:    br label [[END]]
 ; CHECK:       end:
-; CHECK-NEXT:    [[PHI:%.*]] = phi %pair* [ [[A]], [[ENTRY:%.*]] ], [ undef, [[IF_THEN]] ]
+; CHECK-NEXT:    [[PHI:%.*]] = phi %pair* [ [[A]], [[ENTRY:%.*]] ], [ poison, [[IF_THEN]] ]
 ; CHECK-NEXT:    [[GEP:%.*]] = getelementptr inbounds [[PAIR]], %pair* [[PHI]], i32 0, i32 1
 ; CHECK-NEXT:    [[LOAD:%.*]] = load i32, i32* [[GEP]], align 4
 ; CHECK-NEXT:    ret i32 [[LOAD]]
@@ -82,7 +82,7 @@ if.then:
   br label %end
 
 end:
-  %phi = phi %pair* [ %a, %entry], [ undef, %if.then ]
+  %phi = phi %pair* [ %a, %entry], [ poison, %if.then ]
   %gep = getelementptr inbounds %pair, %pair* %phi, i32 0, i32 1
   %load = load i32, i32* %gep, align 4
   ret i32 %load
@@ -312,15 +312,15 @@ end:
   ret i32 %load
 }
 
-define void @test_sroa_gep_phi_select_other_block() {
+define void @test_sroa_gep_phi_select_other_block(i1 %c1, i1 %c2, %pair* %ptr) {
 ; CHECK-LABEL: @test_sroa_gep_phi_select_other_block(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[ALLOCA:%.*]] = alloca [[PAIR:%.*]], align 8
 ; CHECK-NEXT:    br label [[WHILE_BODY:%.*]]
 ; CHECK:       while.body:
 ; CHECK-NEXT:    [[PHI:%.*]] = phi %pair* [ [[ALLOCA]], [[ENTRY:%.*]] ], [ [[SELECT:%.*]], [[WHILE_BODY]] ]
-; CHECK-NEXT:    [[SELECT]] = select i1 undef, %pair* [[PHI]], %pair* undef
-; CHECK-NEXT:    br i1 undef, label [[EXIT:%.*]], label [[WHILE_BODY]]
+; CHECK-NEXT:    [[SELECT]] = select i1 [[C1:%.*]], %pair* [[PHI]], %pair* [[PTR:%.*]]
+; CHECK-NEXT:    br i1 [[C2:%.*]], label [[EXIT:%.*]], label [[WHILE_BODY]]
 ; CHECK:       exit:
 ; CHECK-NEXT:    [[GEP:%.*]] = getelementptr inbounds [[PAIR]], %pair* [[PHI]], i64 1
 ; CHECK-NEXT:    unreachable
@@ -331,27 +331,28 @@ entry:
 
 while.body:
   %phi = phi %pair* [ %alloca, %entry ], [ %select, %while.body ]
-  %select = select i1 undef, %pair* %phi, %pair* undef
-  br i1 undef, label %exit, label %while.body
+  %select = select i1 %c1, %pair* %phi, %pair* %ptr
+  br i1 %c2, label %exit, label %while.body
 
 exit:
   %gep = getelementptr inbounds %pair, %pair* %phi, i64 1
   unreachable
 }
 
-define void @test_sroa_gep_phi_select_same_block() {
+define void @test_sroa_gep_phi_select_same_block(i1 %c1, i1 %c2, %pair* %ptr) {
 ; CHECK-LABEL: @test_sroa_gep_phi_select_same_block(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[ALLOCA:%.*]] = alloca [[PAIR:%.*]], align 8
 ; CHECK-NEXT:    br label [[WHILE_BODY:%.*]]
 ; CHECK:       while.body:
 ; CHECK-NEXT:    [[PHI:%.*]] = phi %pair* [ [[ALLOCA]], [[ENTRY:%.*]] ], [ [[SELECT:%.*]], [[WHILE_BODY]] ]
-; CHECK-NEXT:    [[SELECT]] = select i1 undef, %pair* [[PHI]], %pair* undef
+; CHECK-NEXT:    [[SELECT]] = select i1 [[C1:%.*]], %pair* [[PHI]], %pair* [[PTR:%.*]]
 ; CHECK-NEXT:    [[PHI_SROA_GEP:%.*]] = getelementptr inbounds [[PAIR]], %pair* [[PHI]], i64 1
-; CHECK-NEXT:    [[SELECT_SROA_SEL:%.*]] = select i1 undef, %pair* [[PHI_SROA_GEP]], %pair* poison
-; CHECK-NEXT:    br i1 undef, label [[EXIT:%.*]], label [[WHILE_BODY]]
+; CHECK-NEXT:    [[PTR_SROA_GEP:%.*]] = getelementptr inbounds [[PAIR]], %pair* [[PTR]], i64 1
+; CHECK-NEXT:    [[SELECT_SROA_SEL:%.*]] = select i1 [[C1]], %pair* [[PHI_SROA_GEP]], %pair* [[PTR_SROA_GEP]]
+; CHECK-NEXT:    br i1 [[C2:%.*]], label [[EXIT:%.*]], label [[WHILE_BODY]]
 ; CHECK:       exit:
-; CHECK-NEXT:    unreachable
+; CHECK-NEXT:    ret void
 ;
 entry:
   %alloca = alloca %pair, align 8
@@ -359,12 +360,12 @@ entry:
 
 while.body:
   %phi = phi %pair* [ %alloca, %entry ], [ %select, %while.body ]
-  %select = select i1 undef, %pair* %phi, %pair* undef
+  %select = select i1 %c1, %pair* %phi, %pair* %ptr
   %gep = getelementptr inbounds %pair, %pair* %select, i64 1
-  br i1 undef, label %exit, label %while.body
+  br i1 %c2, label %exit, label %while.body
 
 exit:
-  unreachable
+  ret void
 }
 
 define i32 @test_sroa_gep_cast_phi_gep(i1 %cond) {
@@ -416,7 +417,7 @@ end:
   ret i32 %load
 }
 
-define void @unreachable_term() {
+define void @unreachable_term(i1 %c1) {
 ; CHECK-LABEL: @unreachable_term(
 ; CHECK-NEXT:    [[A_SROA_0:%.*]] = alloca i32, align 4
 ; CHECK-NEXT:    [[A_SROA_0_0_A_SROA_CAST1:%.*]] = bitcast i32* [[A_SROA_0]] to [3 x i32]*
@@ -427,7 +428,7 @@ define void @unreachable_term() {
 ; CHECK-NEXT:    [[PHI:%.*]] = phi [3 x i32]* [ [[A_SROA_0_0_A_SROA_CAST1]], [[BB1:%.*]] ], [ null, [[BB1_I]] ]
 ; CHECK-NEXT:    [[GEP:%.*]] = getelementptr [3 x i32], [3 x i32]* [[PHI]], i64 0, i64 0
 ; CHECK-NEXT:    store i32 0, i32* [[GEP]], align 1
-; CHECK-NEXT:    br i1 undef, label [[BB1_I]], label [[EXIT:%.*]]
+; CHECK-NEXT:    br i1 [[C1:%.*]], label [[BB1_I]], label [[EXIT:%.*]]
 ; CHECK:       exit:
 ; CHECK-NEXT:    br label [[BB2:%.*]]
 ; CHECK:       bb2:
@@ -443,7 +444,7 @@ bb1.i:
   %phi = phi [3 x i32]* [ %a, %bb1 ], [ null, %bb1.i ]
   %gep = getelementptr [3 x i32], [3 x i32]* %phi, i64 0, i64 0
   store i32 0, i32* %gep, align 1
-  br i1 undef, label %bb1.i, label %exit
+  br i1 %c1, label %bb1.i, label %exit
 
 exit:
   br label %bb2
@@ -452,12 +453,12 @@ bb2:
   ret void
 }
 
-define void @constant_value_phi() {
+define void @constant_value_phi(i1 %c1) {
 ; CHECK-LABEL: @constant_value_phi(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[LAND_LHS_TRUE_I:%.*]]
 ; CHECK:       land.lhs.true.i:
-; CHECK-NEXT:    br i1 undef, label [[COND_END_I:%.*]], label [[COND_END_I]]
+; CHECK-NEXT:    br i1 [[C1:%.*]], label [[COND_END_I:%.*]], label [[COND_END_I]]
 ; CHECK:       cond.end.i:
 ; CHECK-NEXT:    unreachable
 ;
@@ -468,7 +469,7 @@ entry:
   br label %land.lhs.true.i
 
 land.lhs.true.i:                                  ; preds = %entry
-  br i1 undef, label %cond.end.i, label %cond.end.i
+  br i1 %c1, label %cond.end.i, label %cond.end.i
 
 cond.end.i:                                       ; preds = %land.lhs.true.i, %land.lhs.true.i
   %.pre-phi1 = phi i16* [ %cast, %land.lhs.true.i ], [ %cast, %land.lhs.true.i ]

diff  --git a/llvm/test/Transforms/SROA/phi-with-duplicate-pred.ll b/llvm/test/Transforms/SROA/phi-with-duplicate-pred.ll
index 2cb650141b479..9d0264faee173 100644
--- a/llvm/test/Transforms/SROA/phi-with-duplicate-pred.ll
+++ b/llvm/test/Transforms/SROA/phi-with-duplicate-pred.ll
@@ -6,10 +6,10 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
 
 declare void @maybe_writes()
 
-define void @f2() {
+define void @f2(i1 %c1) {
 ; CHECK-LABEL: @f2(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br i1 undef, label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
+; CHECK-NEXT:    br i1 [[C1:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
 ; CHECK:       if.then:
 ; CHECK-NEXT:    br label [[CLEANUP:%.*]]
 ; CHECK:       cleanup:
@@ -28,7 +28,7 @@ define void @f2() {
 ;
 entry:
   %e = alloca i16, align 1
-  br i1 undef, label %if.then, label %if.else
+  br i1 %c1, label %if.then, label %if.else
 
 if.then:                                          ; preds = %entry
   br label %cleanup
@@ -51,11 +51,11 @@ cleanup7:                                         ; preds = %cleanup
   ret void
 }
 
-define void @f3() {
+define void @f3(i1 %c1) {
 ; CHECK-LABEL: @f3(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[E:%.*]] = alloca i16, align 1
-; CHECK-NEXT:    br i1 undef, label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
+; CHECK-NEXT:    br i1 [[C1:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
 ; CHECK:       if.then:
 ; CHECK-NEXT:    br label [[CLEANUP:%.*]]
 ; CHECK:       cleanup:
@@ -76,7 +76,7 @@ define void @f3() {
 ;
 entry:
   %e = alloca i16, align 1
-  br i1 undef, label %if.then, label %if.else
+  br i1 %c1, label %if.then, label %if.else
 
 if.then:                                          ; preds = %entry
   br label %cleanup
@@ -102,11 +102,11 @@ cleanup7:                                         ; preds = %cleanup
   ret void
 }
 
-define void @f4() {
+define void @f4(i1 %c1) {
 ; CHECK-LABEL: @f4(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[E:%.*]] = alloca i16, align 1
-; CHECK-NEXT:    br i1 undef, label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
+; CHECK-NEXT:    br i1 [[C1:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
 ; CHECK:       if.then:
 ; CHECK-NEXT:    br label [[CLEANUP:%.*]]
 ; CHECK:       cleanup:
@@ -128,7 +128,7 @@ define void @f4() {
 ;
 entry:
   %e = alloca i16, align 1
-  br i1 undef, label %if.then, label %if.else
+  br i1 %c1, label %if.then, label %if.else
 
 if.then:                                          ; preds = %entry
   br label %cleanup
@@ -155,11 +155,11 @@ cleanup7:                                         ; preds = %cleanup
   ret void
 }
 
-define void @f5() {
+define void @f5(i1 %c1, i1 %c2) {
 ; CHECK-LABEL: @f5(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[E:%.*]] = alloca i16, align 1
-; CHECK-NEXT:    br i1 undef, label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
+; CHECK-NEXT:    br i1 [[C1:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
 ; CHECK:       if.then:
 ; CHECK-NEXT:    br label [[CLEANUP:%.*]]
 ; CHECK:       cleanup:
@@ -171,7 +171,7 @@ define void @f5() {
 ; CHECK-NEXT:    br label [[LBL1]]
 ; CHECK:       lbl1:
 ; CHECK-NEXT:    [[G_0:%.*]] = phi i16* [ @a, [[CLEANUP]] ], [ @a, [[CLEANUP]] ], [ [[E]], [[IF_ELSE]] ]
-; CHECK-NEXT:    br i1 undef, label [[FINAL:%.*]], label [[CLEANUP7]]
+; CHECK-NEXT:    br i1 [[C2:%.*]], label [[FINAL:%.*]], label [[CLEANUP7]]
 ; CHECK:       final:
 ; CHECK-NEXT:    [[TMP0:%.*]] = load i16, i16* [[G_0]], align 1
 ; CHECK-NEXT:    unreachable
@@ -180,7 +180,7 @@ define void @f5() {
 ;
 entry:
   %e = alloca i16, align 1
-  br i1 undef, label %if.then, label %if.else
+  br i1 %c1, label %if.then, label %if.else
 
 if.then:                                          ; preds = %entry
   br label %cleanup
@@ -196,7 +196,7 @@ if.else:                                          ; preds = %entry
 
 lbl1:                                             ; preds = %if.else, %cleanup, %cleanup
   %g.0 = phi i16* [ @a, %cleanup ], [ @a, %cleanup ], [ %e, %if.else ]
-  br i1 undef, label %final, label %cleanup7
+  br i1 %c2, label %final, label %cleanup7
 
 final:
   %0 = load i16, i16* %g.0, align 1
@@ -206,11 +206,11 @@ cleanup7:                                         ; preds = %cleanup
   ret void
 }
 
-define void @f6() {
+define void @f6(i1 %c1) {
 ; CHECK-LABEL: @f6(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[E:%.*]] = alloca i16, align 1
-; CHECK-NEXT:    br i1 undef, label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
+; CHECK-NEXT:    br i1 [[C1:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
 ; CHECK:       if.then:
 ; CHECK-NEXT:    br label [[CLEANUP:%.*]]
 ; CHECK:       cleanup:
@@ -234,7 +234,7 @@ define void @f6() {
 ;
 entry:
   %e = alloca i16, align 1
-  br i1 undef, label %if.then, label %if.else
+  br i1 %c1, label %if.then, label %if.else
 
 if.then:                                          ; preds = %entry
   br label %cleanup

diff  --git a/llvm/test/Transforms/SROA/select-gep.ll b/llvm/test/Transforms/SROA/select-gep.ll
index 9b3a7dd797fb5..91f497daf4a1a 100644
--- a/llvm/test/Transforms/SROA/select-gep.ll
+++ b/llvm/test/Transforms/SROA/select-gep.ll
@@ -79,8 +79,8 @@ bb:
   ret i32 %add
 }
 
-define i32 @test_sroa_select_gep_undef(i1 %cond) {
-; CHECK-LABEL: @test_sroa_select_gep_undef(
+define i32 @test_sroa_select_gep_poison(i1 %cond) {
+; CHECK-LABEL: @test_sroa_select_gep_poison(
 ; CHECK-NEXT:  bb:
 ; CHECK-NEXT:    [[A_SROA_0:%.*]] = alloca i32, align 4
 ; CHECK-NEXT:    [[SELECT_SROA_SEL:%.*]] = select i1 [[COND:%.*]], i32* [[A_SROA_0]], i32* poison
@@ -89,7 +89,7 @@ define i32 @test_sroa_select_gep_undef(i1 %cond) {
 ;
 bb:
   %a = alloca %pair, align 4
-  %select = select i1 %cond, %pair* %a, %pair* undef
+  %select = select i1 %cond, %pair* %a, %pair* poison
   %gep = getelementptr inbounds %pair, %pair* %select, i32 0, i32 1
   %load = load i32, i32* %gep, align 4
   ret i32 %load

diff  --git a/llvm/test/Transforms/SROA/select-load.ll b/llvm/test/Transforms/SROA/select-load.ll
index 841508e4d50c3..a670b4740aa30 100644
--- a/llvm/test/Transforms/SROA/select-load.ll
+++ b/llvm/test/Transforms/SROA/select-load.ll
@@ -11,7 +11,7 @@ define <2 x i16> @test_load_bitcast_select(i1 %cond1, i1 %cond2) {
 ; CHECK-NEXT:    [[TMP0:%.*]] = bitcast half 0xHFFFF to i16
 ; CHECK-NEXT:    [[TMP1:%.*]] = bitcast half 0xH0000 to i16
 ; CHECK-NEXT:    [[LD1_SROA_SPECULATED:%.*]] = select i1 [[COND1:%.*]], i16 [[TMP0]], i16 [[TMP1]]
-; CHECK-NEXT:    [[V1:%.*]] = insertelement <2 x i16> undef, i16 [[LD1_SROA_SPECULATED]], i32 0
+; CHECK-NEXT:    [[V1:%.*]] = insertelement <2 x i16> poison, i16 [[LD1_SROA_SPECULATED]], i32 0
 ; CHECK-NEXT:    [[TMP2:%.*]] = bitcast half 0xHFFFF to i16
 ; CHECK-NEXT:    [[TMP3:%.*]] = bitcast half 0xH0000 to i16
 ; CHECK-NEXT:    [[LD2_SROA_SPECULATED:%.*]] = select i1 [[COND2:%.*]], i16 [[TMP2]], i16 [[TMP3]]
@@ -28,7 +28,7 @@ entry:
   %sel1 = select i1 %cond1, %st.half* %true.cast, %st.half* %false.cast
   %cast1 = bitcast %st.half* %sel1 to i16*
   %ld1 = load i16, i16* %cast1, align 2
-  %v1 = insertelement <2 x i16> undef, i16 %ld1, i32 0
+  %v1 = insertelement <2 x i16> poison, i16 %ld1, i32 0
   %sel2 = select i1 %cond2, %st.half* %true.cast, %st.half* %false.cast
   %cast2 = bitcast %st.half* %sel2 to i16*
   %ld2 = load i16, i16* %cast2, align 2

diff  --git a/llvm/test/Transforms/SROA/vector-promotion-
diff erent-size.ll b/llvm/test/Transforms/SROA/vector-promotion-
diff erent-size.ll
index ff7a5319f2dbe..d7321556ccd42 100644
--- a/llvm/test/Transforms/SROA/vector-promotion-
diff erent-size.ll
+++ b/llvm/test/Transforms/SROA/vector-promotion-
diff erent-size.ll
@@ -1,24 +1,35 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt < %s -passes=sroa -S | FileCheck %s
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n8:16:32:64"
 
 define <4 x i1> @vector_bitcast() {
-  ; CHECK-LABEL: @vector_bitcast
-  ; CHECK: alloca <3 x i1>
+; CHECK-LABEL: @vector_bitcast(
+; CHECK-NEXT:    [[A:%.*]] = alloca <3 x i1>, align 1
+; CHECK-NEXT:    store <3 x i1> <i1 true, i1 false, i1 true>, <3 x i1>* [[A]], align 1
+; CHECK-NEXT:    [[A_0_CAST_SROA_CAST:%.*]] = bitcast <3 x i1>* [[A]] to <4 x i1>*
+; CHECK-NEXT:    [[A_0_VEC:%.*]] = load <4 x i1>, <4 x i1>* [[A_0_CAST_SROA_CAST]], align 1
+; CHECK-NEXT:    ret <4 x i1> [[A_0_VEC]]
+;
 
-    %a = alloca <3 x i1>
-    store <3 x i1> <i1 1,i1 0,i1 1>, <3 x i1>* %a
-    %cast = bitcast <3 x i1>* %a to <4 x i1>*
-    %vec = load <4 x i1>, <4 x i1>* %cast
-    ret <4 x i1> %vec
+  %a = alloca <3 x i1>
+  store <3 x i1> <i1 1,i1 0,i1 1>, <3 x i1>* %a
+  %cast = bitcast <3 x i1>* %a to <4 x i1>*
+  %vec = load <4 x i1>, <4 x i1>* %cast
+  ret <4 x i1> %vec
 }
 
-define void @vector_bitcast_2() {
-  ; CHECK-LABEL: @vector_bitcast_2
-  ; CHECK: alloca <32 x i16>
+define void @vector_bitcast_2(<32 x i16> %v) {
+; CHECK-LABEL: @vector_bitcast_2(
+; CHECK-NEXT:    %"sum$1.host2" = alloca <32 x i16>, align 64
+; CHECK-NEXT:    store <32 x i16> [[V:%.*]], <32 x i16>* %"sum$1.host2", align 64
+; CHECK-NEXT:    %"sum$1.host2.0.bc.sroa_cast" = bitcast <32 x i16>* %"sum$1.host2" to <64 x i16>*
+; CHECK-NEXT:    %"sum$1.host2.0.bcl" = load <64 x i16>, <64 x i16>* %"sum$1.host2.0.bc.sroa_cast", align 64
+; CHECK-NEXT:    ret void
+;
 
-    %"sum$1.host2" = alloca <32 x i16>
-    store <32 x i16> undef, <32 x i16>* %"sum$1.host2"
-    %bc = bitcast <32 x i16>* %"sum$1.host2" to <64 x i16>*
-    %bcl = load <64 x i16>, <64 x i16>* %bc
-    ret void
+  %"sum$1.host2" = alloca <32 x i16>
+  store <32 x i16> %v, <32 x i16>* %"sum$1.host2"
+  %bc = bitcast <32 x i16>* %"sum$1.host2" to <64 x i16>*
+  %bcl = load <64 x i16>, <64 x i16>* %bc
+  ret void
 }

diff  --git a/llvm/test/Transforms/SROA/vector-promotion.ll b/llvm/test/Transforms/SROA/vector-promotion.ll
index e63c32300ffac..c1e7cd6aa8aae 100644
--- a/llvm/test/Transforms/SROA/vector-promotion.ll
+++ b/llvm/test/Transforms/SROA/vector-promotion.ll
@@ -407,10 +407,10 @@ entry:
   ret <4 x float> %ret
 }
 
-define i32 @PR14212() {
+define i32 @PR14212(<3 x i8> %val) {
 ; CHECK-LABEL: @PR14212(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[TMP0:%.*]] = bitcast <3 x i8> undef to i24
+; CHECK-NEXT:    [[TMP0:%.*]] = bitcast <3 x i8> [[VAL:%.*]] to i24
 ; CHECK-NEXT:    [[RETVAL_SROA_2_0_INSERT_EXT:%.*]] = zext i8 undef to i32
 ; CHECK-NEXT:    [[RETVAL_SROA_2_0_INSERT_SHIFT:%.*]] = shl i32 [[RETVAL_SROA_2_0_INSERT_EXT]], 24
 ; CHECK-NEXT:    [[RETVAL_SROA_2_0_INSERT_MASK:%.*]] = and i32 undef, 16777215
@@ -425,7 +425,7 @@ define i32 @PR14212() {
 entry:
   %retval = alloca <3 x i8>, align 4
 
-  store <3 x i8> undef, <3 x i8>* %retval, align 4
+  store <3 x i8> %val, <3 x i8>* %retval, align 4
   %cast = bitcast <3 x i8>* %retval to i32*
   %load = load i32, i32* %cast, align 4
   ret i32 %load
@@ -612,15 +612,15 @@ entry:
   ret <2 x float> %result
 }
 
-define <4 x float> @test12() {
+define <4 x float> @test12(<4 x i32> %val) {
 ; CHECK-LABEL: @test12(
-; CHECK-NEXT:    [[TMP1:%.*]] = bitcast <4 x i32> undef to <4 x float>
+; CHECK-NEXT:    [[TMP1:%.*]] = bitcast <4 x i32> [[VAL:%.*]] to <4 x float>
 ; CHECK-NEXT:    ret <4 x float> [[TMP1]]
 ;
   %a = alloca <3 x i32>, align 16
 
   %cast1 = bitcast <3 x i32>* %a to <4 x i32>*
-  store <4 x i32> undef, <4 x i32>* %cast1, align 16
+  store <4 x i32> %val, <4 x i32>* %cast1, align 16
 
   %cast2 = bitcast <3 x i32>* %a to <3 x float>*
   %cast3 = bitcast <3 x float>* %cast2 to <4 x float>*

diff  --git a/llvm/test/Transforms/SROA/vectors-of-pointers.ll b/llvm/test/Transforms/SROA/vectors-of-pointers.ll
index ff09e95989657..a746f8bbbc0c2 100644
--- a/llvm/test/Transforms/SROA/vectors-of-pointers.ll
+++ b/llvm/test/Transforms/SROA/vectors-of-pointers.ll
@@ -5,21 +5,21 @@
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.8.0"
 
-define void @foo() {
+define void @foo(i1 %c1, i1 %c2) {
 entry:
   %Args.i = alloca <2 x i32*>, align 16
-  br i1 undef, label %bb0.exit158, label %if.then.i.i.i.i.i138
+  br i1 %c1, label %bb0.exit158, label %if.then.i.i.i.i.i138
 
 if.then.i.i.i.i.i138:
-  unreachable
+  ret void
 
 bb0.exit158:
-  br i1 undef, label %bb0.exit257, label %if.then.i.i.i.i.i237
+  br i1 %c2, label %bb0.exit257, label %if.then.i.i.i.i.i237
 
 if.then.i.i.i.i.i237:
   unreachable
 
 bb0.exit257:
   %0 = load <2 x i32*>, <2 x i32*>* %Args.i, align 16
-  unreachable
+  ret void
 }


        


More information about the llvm-commits mailing list