[llvm-commits] [llvm] r90545 - in /llvm/trunk: lib/Analysis/ConstantFolding.cpp test/Transforms/ConstProp/loads.ll

Chris Lattner sabre at nondot.org
Thu Dec 3 22:29:30 PST 2009


Author: lattner
Date: Fri Dec  4 00:29:29 2009
New Revision: 90545

URL: http://llvm.org/viewvc/llvm-project?rev=90545&view=rev
Log:
Fix PR5551 by not ignoring the top level constantexpr when
folding a load from constant.

Modified:
    llvm/trunk/lib/Analysis/ConstantFolding.cpp
    llvm/trunk/test/Transforms/ConstProp/loads.ll

Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=90545&r1=90544&r2=90545&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Fri Dec  4 00:29:29 2009
@@ -432,7 +432,7 @@
   // Instead of loading constant c string, use corresponding integer value
   // directly if string length is small enough.
   std::string Str;
-  if (TD && GetConstantStringInfo(CE->getOperand(0), Str) && !Str.empty()) {
+  if (TD && GetConstantStringInfo(CE, Str) && !Str.empty()) {
     unsigned StrLen = Str.length();
     const Type *Ty = cast<PointerType>(CE->getType())->getElementType();
     unsigned NumBits = Ty->getPrimitiveSizeInBits();

Modified: llvm/trunk/test/Transforms/ConstProp/loads.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ConstProp/loads.ll?rev=90545&r1=90544&r2=90545&view=diff

==============================================================================
--- llvm/trunk/test/Transforms/ConstProp/loads.ll (original)
+++ llvm/trunk/test/Transforms/ConstProp/loads.ll Fri Dec  4 00:29:29 2009
@@ -101,3 +101,12 @@
 }
 
 
+; PR5551
+ at test12g = private constant [6 x i8] c"a\00b\00\00\00"
+
+define i16 @test12() {
+  %a = load i16* getelementptr inbounds ([3 x i16]* bitcast ([6 x i8]* @test12g to [3 x i16]*), i32 0, i64 1) 
+  ret i16 %a
+; CHECK: @test12
+; CHECK: ret i16 98
+}





More information about the llvm-commits mailing list