summaryrefslogtreecommitdiffstats
path: root/lib/IR/ConstantFold.cpp
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2015-05-21 06:57:07 +0000
committerdim <dim@FreeBSD.org>2015-05-21 06:57:07 +0000
commit6669eceb008a9f13853b330dc0b099d6386fe879 (patch)
tree311f96478e9fceea407d1f187f9c5cef712f796e /lib/IR/ConstantFold.cpp
parentea50228cd2ebf54c0ec67624d82c47a11b807869 (diff)
downloadFreeBSD-src-6669eceb008a9f13853b330dc0b099d6386fe879.zip
FreeBSD-src-6669eceb008a9f13853b330dc0b099d6386fe879.tar.gz
Vendor import of llvm RELEASE_361/final tag r237755 (effectively, 3.6.1 release):
https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_361/final@237755
Diffstat (limited to 'lib/IR/ConstantFold.cpp')
-rw-r--r--lib/IR/ConstantFold.cpp33
1 files changed, 12 insertions, 21 deletions
diff --git a/lib/IR/ConstantFold.cpp b/lib/IR/ConstantFold.cpp
index 9176bf2..39d9a1d 100644
--- a/lib/IR/ConstantFold.cpp
+++ b/lib/IR/ConstantFold.cpp
@@ -1120,27 +1120,18 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
return ConstantInt::get(CI1->getContext(), C1V | C2V);
case Instruction::Xor:
return ConstantInt::get(CI1->getContext(), C1V ^ C2V);
- case Instruction::Shl: {
- uint32_t shiftAmt = C2V.getZExtValue();
- if (shiftAmt < C1V.getBitWidth())
- return ConstantInt::get(CI1->getContext(), C1V.shl(shiftAmt));
- else
- return UndefValue::get(C1->getType()); // too big shift is undef
- }
- case Instruction::LShr: {
- uint32_t shiftAmt = C2V.getZExtValue();
- if (shiftAmt < C1V.getBitWidth())
- return ConstantInt::get(CI1->getContext(), C1V.lshr(shiftAmt));
- else
- return UndefValue::get(C1->getType()); // too big shift is undef
- }
- case Instruction::AShr: {
- uint32_t shiftAmt = C2V.getZExtValue();
- if (shiftAmt < C1V.getBitWidth())
- return ConstantInt::get(CI1->getContext(), C1V.ashr(shiftAmt));
- else
- return UndefValue::get(C1->getType()); // too big shift is undef
- }
+ case Instruction::Shl:
+ if (C2V.ult(C1V.getBitWidth()))
+ return ConstantInt::get(CI1->getContext(), C1V.shl(C2V));
+ return UndefValue::get(C1->getType()); // too big shift is undef
+ case Instruction::LShr:
+ if (C2V.ult(C1V.getBitWidth()))
+ return ConstantInt::get(CI1->getContext(), C1V.lshr(C2V));
+ return UndefValue::get(C1->getType()); // too big shift is undef
+ case Instruction::AShr:
+ if (C2V.ult(C1V.getBitWidth()))
+ return ConstantInt::get(CI1->getContext(), C1V.ashr(C2V));
+ return UndefValue::get(C1->getType()); // too big shift is undef
}
}
OpenPOWER on IntegriCloud