Make SROA produce a vector only when the alloca is actually
authorChris Lattner <sabre@nondot.org>
Tue, 3 Feb 2009 18:15:05 +0000 (18:15 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 3 Feb 2009 18:15:05 +0000 (18:15 +0000)
commit1a3257bbf53eff4c7cfcbef972dd382f7baa7592
tree7d60231912299c206c4ec23545d341fc788b18d3
parent67e3ba3f1dda6a5e4a9c774fbf0f96ec18db111a
Make SROA produce a vector only when the alloca is actually
accessed at least once as a vector.  This prevents it from
compiling the example in not-a-vector into:

define double @test(double %A, double %B) {
%tmp4 = insertelement <7 x double> undef, double %A, i32 0
%tmp = insertelement <7 x double> %tmp4, double %B, i32 4
%tmp2 = extractelement <7 x double> %tmp, i32 4
ret double %tmp2
}

instead, producing the integer code.  Producing vectors when they
aren't otherwise in the program is dangerous because a lot of other
code treats them carefully and doesn't want to break them down.
OTOH, many things want to break down tasty i448's.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63638 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/ScalarReplAggregates.cpp
test/Transforms/ScalarRepl/not-a-vector.ll [new file with mode: 0644]