[llvm-commits] [llvm] r132766 - in /llvm/trunk: lib/Transforms/Scalar/ScalarReplAggregates.cpp test/Transforms/ScalarRepl/2011-06-08-VectorExtractValue.ll

Cameron Zwarich zwarich at apple.com
Wed Jun 8 18:45:33 PDT 2011


Author: zwarich
Date: Wed Jun  8 20:45:33 2011
New Revision: 132766

URL: http://llvm.org/viewvc/llvm-project?rev=132766&view=rev
Log:
Fix PR10104 by adding a bounds check on a vector element access check. It was
assuming that all offsets are legal vector accesses, and thus trying to access
the float member of { <2 x float>, float } as the 3rd element of the first
member.

Modified:
    llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
    llvm/trunk/test/Transforms/ScalarRepl/2011-06-08-VectorExtractValue.ll

Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=132766&r1=132765&r2=132766&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Wed Jun  8 20:45:33 2011
@@ -342,7 +342,10 @@
     // If we're accessing something that could be an element of a vector, see
     // if the implied vector agrees with what we already have and if Offset is
     // compatible with it.
-    if (Offset % EltSize == 0 && AllocaSize % EltSize == 0) {
+    if (Offset % EltSize == 0 && AllocaSize % EltSize == 0 &&
+        Offset * 8 <
+          (VectorTy ? VectorTy->getPrimitiveSizeInBits()
+                    : (AllocaSize / EltSize) * In->getPrimitiveSizeInBits())) {
       if (!VectorTy) {
         VectorTy = VectorType::get(In, AllocaSize/EltSize);
         return;

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=132766&r1=132765&r2=132766&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/ScalarRepl/2011-06-08-VectorExtractValue.ll (original)
+++ llvm/trunk/test/Transforms/ScalarRepl/2011-06-08-VectorExtractValue.ll Wed Jun  8 20:45:33 2011
@@ -41,9 +41,11 @@
 
 ; CHECK: test2
 ; CHECK-NOT: alloca
-; CHECK: insertelement <2 x float> zeroinitializer
-; CHECK: extractelement <2 x float> %tmp2
-; CHECK: extractelement <2 x float> %tmp2
+; CHECK: and i128
+; CHECK: or i128
+; CHECK: trunc i128
+; CHECK-NOT: insertelement
+; CHECK-NOT: extractelement
 
 define float @test2() uwtable ssp {
 entry:





More information about the llvm-commits mailing list