[llvm-commits] [llvm] r170331 - /llvm/trunk/lib/Transforms/Scalar/SROA.cpp

Chandler Carruth chandlerc at gmail.com
Mon Dec 17 05:51:03 PST 2012


Author: chandlerc
Date: Mon Dec 17 07:51:03 2012
New Revision: 170331

URL: http://llvm.org/viewvc/llvm-project?rev=170331&view=rev
Log:
Hoist a convertValue call to the two paths where it is needed.

I noticed this while looking at r170328. We only ever do a vector
rewrite when the alloca *is* the vector type, so it's good to not paper
over bugs here by doing a convertValue that isn't needed.

Modified:
    llvm/trunk/lib/Transforms/Scalar/SROA.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/SROA.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SROA.cpp?rev=170331&r1=170330&r2=170331&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SROA.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SROA.cpp Mon Dec 17 07:51:03 2012
@@ -2807,6 +2807,7 @@
         assert(V->getType() == IntTy &&
                "Wrong type for an alloca wide integer!");
       }
+      V = convertValue(TD, IRB, V, AllocaTy);
     } else {
       // Established these invariants above.
       assert(BeginOffset == NewAllocaBeginOffset);
@@ -2814,13 +2815,13 @@
 
       V = getIntegerSplat(IRB, II.getValue(),
                           TD.getTypeSizeInBits(ScalarTy)/8);
-
       if (VectorType *AllocaVecTy = dyn_cast<VectorType>(AllocaTy))
         V = getVectorSplat(IRB, V, AllocaVecTy->getNumElements());
+
+      V = convertValue(TD, IRB, V, AllocaTy);
     }
 
-    Value *New = IRB.CreateAlignedStore(convertValue(TD, IRB, V, AllocaTy),
-                                        &NewAI, NewAI.getAlignment(),
+    Value *New = IRB.CreateAlignedStore(V, &NewAI, NewAI.getAlignment(),
                                         II.isVolatile());
     (void)New;
     DEBUG(dbgs() << "          to: " << *New << "\n");





More information about the llvm-commits mailing list