summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ConstantFolding.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-08 19:02:23 +0000
committerChris Lattner <sabre@nondot.org>2010-01-08 19:02:23 +0000
commita69f89c17a85d504d31a187111e5f0a0677c1921 (patch)
tree268c32254e475fcd3cc93dd8ac7c3bfa81c1425f /llvm/lib/Analysis/ConstantFolding.cpp
parentb92304b42f7f7b9b294d9e7dd7ab96002dff5b97 (diff)
downloadbcm5719-llvm-a69f89c17a85d504d31a187111e5f0a0677c1921.tar.gz
bcm5719-llvm-a69f89c17a85d504d31a187111e5f0a0677c1921.zip
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. llvm-svn: 93018
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r--llvm/lib/Analysis/ConstantFolding.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 194cabaf978..4ae8859a257 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -398,8 +398,8 @@ static Constant *FoldReinterpretLoadFromConstPtr(Constant *C,
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]);
}
OpenPOWER on IntegriCloud