[llvm-commits] [llvm] r133338 - in /llvm/trunk: lib/Transforms/Scalar/ScalarReplAggregates.cpp test/Transforms/ScalarRepl/2011-06-08-VectorExtractValue.ll test/Transforms/ScalarRepl/2011-06-17-VectorPartialMemset.ll
Cameron Zwarich
zwarich at apple.com
Fri Jun 17 23:17:51 PDT 2011
Author: zwarich
Date: Sat Jun 18 01:17:51 2011
New Revision: 133338
URL: http://llvm.org/viewvc/llvm-project?rev=133338&view=rev
Log:
When scalar replacement returns a vector type, only accept it if the vector
type's bitwidth matches the (allocated) size of the alloca. This severely
pessimizes vector scalar replacement when the only vector type being used is
something like <3 x float> on x86 or ARM whose allocated size matches a
<4 x float>.
I hope to fix some of the flawed assumptions about allocated size throughout
scalar replacement and reenable this in most cases.
Modified:
llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
llvm/trunk/test/Transforms/ScalarRepl/2011-06-08-VectorExtractValue.ll
llvm/trunk/test/Transforms/ScalarRepl/2011-06-17-VectorPartialMemset.ll
Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=133338&r1=133337&r2=133338&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Sat Jun 18 01:17:51 2011
@@ -293,6 +293,11 @@
if (ScalarKind == Unknown)
ScalarKind = Integer;
+ // FIXME: It should be possible to promote the vector type up to the alloca's
+ // size.
+ if (ScalarKind == Vector && VectorTy->getBitWidth() != AllocaSize * 8)
+ ScalarKind = Integer;
+
// If we were able to find a vector type that can handle this with
// insert/extract elements, and if there was at least one use that had
// a vector type, promote this to a vector. We don't want to promote
Modified: llvm/trunk/test/Transforms/ScalarRepl/2011-06-08-VectorExtractValue.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/2011-06-08-VectorExtractValue.ll?rev=133338&r1=133337&r2=133338&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/ScalarRepl/2011-06-08-VectorExtractValue.ll (original)
+++ llvm/trunk/test/Transforms/ScalarRepl/2011-06-08-VectorExtractValue.ll Sat Jun 18 01:17:51 2011
@@ -10,7 +10,8 @@
; CHECK: main
; CHECK-NOT: alloca
-; CHECK: extractelement <2 x float> zeroinitializer
+; CHECK: %[[A:[a-z0-9]*]] = and i128
+; CHECK: %[[B:[a-z0-9]*]] = trunc i128 %[[A]] to i32
define void @main() uwtable ssp {
entry:
@@ -27,7 +28,8 @@
; CHECK: test1
; CHECK-NOT: alloca
-; CHECK: extractelement <2 x float> zeroinitializer
+; CHECK: %[[A:[a-z0-9]*]] = and i128
+; CHECK: %[[B:[a-z0-9]*]] = trunc i128 %[[A]] to i32
define void @test1() uwtable ssp {
entry:
Modified: llvm/trunk/test/Transforms/ScalarRepl/2011-06-17-VectorPartialMemset.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/2011-06-17-VectorPartialMemset.ll?rev=133338&r1=133337&r2=133338&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/ScalarRepl/2011-06-17-VectorPartialMemset.ll (original)
+++ llvm/trunk/test/Transforms/ScalarRepl/2011-06-17-VectorPartialMemset.ll Sat Jun 18 01:17:51 2011
@@ -19,4 +19,19 @@
ret float %val
}
+; CHECK: g
+; CHECK-NOT: alloca
+; CHECK: and i128
+
+define void @g() nounwind ssp {
+entry:
+ %a = alloca { <4 x float> }, align 16
+ %p = bitcast { <4 x float> }* %a to i8*
+ call void @llvm.memset.p0i8.i32(i8* %p, i8 0, i32 16, i32 16, i1 false)
+ %q = bitcast { <4 x float> }* %a to [2 x <2 x float>]*
+ %arrayidx = getelementptr inbounds [2 x <2 x float>]* %q, i32 0, i32 0
+ store <2 x float> undef, <2 x float>* %arrayidx, align 8
+ ret void
+}
+
declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1) nounwind
More information about the llvm-commits
mailing list