Index: lib/Transforms/Scalar/SROA.cpp =================================================================== --- lib/Transforms/Scalar/SROA.cpp +++ lib/Transforms/Scalar/SROA.cpp @@ -1684,6 +1684,10 @@ } if (!canConvertValue(DL, STy, SliceTy)) return false; + } else if (IntrinsicInst *II = dyn_cast(U->getUser())) { + if (II->getIntrinsicID() != Intrinsic::lifetime_start && + II->getIntrinsicID() != Intrinsic::lifetime_end) + return false; } else { return false; } Index: test/Transforms/SROA/vector-lifetime.ll =================================================================== --- /dev/null +++ test/Transforms/SROA/vector-lifetime.ll @@ -0,0 +1,28 @@ +; RUN: opt %s -sroa -S -o - | 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" + +declare void @llvm.lifetime.start(i64, i8* nocapture) +declare void @llvm.lifetime.end(i64, i8* nocapture) + +declare <4 x float> @bar() + +define void @foo(<3 x float>* %dst) { + %buf = alloca <4 x float>, align 16 + %buf.i8 = bitcast <4 x float>* %buf to i8* + call void @llvm.lifetime.start(i64 16, i8* %buf.i8) + %v4 = call <4 x float> @bar() + store <4 x float> %v4, <4 x float>* %buf, align 16 + %buf.cast = bitcast <4 x float>* %buf to <3 x float>* + %v3 = load <3 x float>* %buf.cast, align 16 + store <3 x float> %v3, <3 x float>* %dst + call void @llvm.lifetime.end(i64 16, i8* %buf.i8) + ret void +} + +; CHECK-LABEL: foo +; CHECK-NOT: alloca +; CHECK: call +; CHECK-NOT: load +; CHECK: store +; CHECK-NEXT: ret