summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/ConstantFold.cpp
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2011-01-14 00:37:45 +0000
committerDuncan Sands <baldrick@free.fr>2011-01-14 00:37:45 +0000
commit7f60dc1eb07e712f51b2768700263a32b1f184e3 (patch)
tree5c28705aa2e742beff119c358208150c2ff97fa9 /llvm/lib/VMCore/ConstantFold.cpp
parentae6ce377c2370800765a92720ead1c52e10e9cbc (diff)
downloadbcm5719-llvm-7f60dc1eb07e712f51b2768700263a32b1f184e3.tar.gz
bcm5719-llvm-7f60dc1eb07e712f51b2768700263a32b1f184e3.zip
Move some shift transforms out of instcombine and into InstructionSimplify.
While there, I noticed that the transform "undef >>a X -> undef" was wrong. For example if X is 2 then the top two bits must be equal, so the result can not be anything. I fixed this in the constant folder as well. Also, I made the transform for "X << undef" stronger: it now folds to undef always, even though X might be zero. This is in accordance with the LangRef, but I must admit that it is fairly aggressive. Also, I added "i32 X << 32 -> undef" following the LangRef and the constant folder, likewise fairly aggressive. llvm-svn: 123417
Diffstat (limited to 'llvm/lib/VMCore/ConstantFold.cpp')
-rw-r--r--llvm/lib/VMCore/ConstantFold.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/VMCore/ConstantFold.cpp b/llvm/lib/VMCore/ConstantFold.cpp
index 27676562d4d..3dc78470ff8 100644
--- a/llvm/lib/VMCore/ConstantFold.cpp
+++ b/llvm/lib/VMCore/ConstantFold.cpp
@@ -977,8 +977,8 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
return Constant::getNullValue(C1->getType()); // X lshr undef -> 0
// undef lshr X -> 0
case Instruction::AShr:
- if (!isa<UndefValue>(C2))
- return C1; // undef ashr X --> undef
+ if (!isa<UndefValue>(C2)) // undef ashr X --> all ones
+ return Constant::getAllOnesValue(C1->getType());
else if (isa<UndefValue>(C1))
return C1; // undef ashr undef -> undef
else
OpenPOWER on IntegriCloud