[llvm-commits] [llvm] r93018 - in /llvm/trunk: lib/Analysis/ConstantFolding.cpp test/Transforms/ConstProp/loads.ll
Chris Lattner
sabre at nondot.org
Fri Jan 8 11:02:24 PST 2010
Author: lattner
Date: Fri Jan 8 13:02:23 2010
New Revision: 93018
URL: http://llvm.org/viewvc/llvm-project?rev=93018&view=rev
Log:
fix PR5978 by peeling the loop so that we avoid shifting the
result int by 8 for the first byte. While normally harmless,
if the result is smaller than a byte, this shift is invalid.
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=93018&r1=93017&r2=93018&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Fri Jan 8 13:02:23 2010
@@ -398,8 +398,8 @@
BytesLoaded, TD))
return 0;
- APInt ResultVal(IntType->getBitWidth(), 0);
- for (unsigned i = 0; i != BytesLoaded; ++i) {
+ APInt ResultVal = APInt(IntType->getBitWidth(), RawBytes[BytesLoaded-1]);
+ for (unsigned i = 1; i != BytesLoaded; ++i) {
ResultVal <<= 8;
ResultVal |= APInt(IntType->getBitWidth(), RawBytes[BytesLoaded-1-i]);
}
Modified: llvm/trunk/test/Transforms/ConstProp/loads.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ConstProp/loads.ll?rev=93018&r1=93017&r2=93018&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/ConstProp/loads.ll (original)
+++ llvm/trunk/test/Transforms/ConstProp/loads.ll Fri Jan 8 13:02:23 2010
@@ -110,3 +110,13 @@
; CHECK: @test12
; CHECK: ret i16 98
}
+
+
+; PR5978
+ at g5 = constant i8 4
+define i1 @test13() {
+ %A = load i1* bitcast (i8* @g5 to i1*)
+ ret i1 %A
+; CHECK: @test13
+; CHECK: ret i1 false
+}
More information about the llvm-commits
mailing list