[llvm-commits] [llvm] r40125 - /llvm/trunk/lib/VMCore/ConstantFold.cpp
Chris Lattner
sabre at nondot.org
Fri Jul 20 15:09:02 PDT 2007
Author: lattner
Date: Fri Jul 20 17:09:02 2007
New Revision: 40125
URL: http://llvm.org/viewvc/llvm-project?rev=40125&view=rev
Log:
zext(undef) = 0 and sext(undef) = 0, not undef.
This hopefully fixes a miscompilation of TargetData.cpp when self hosting.
Modified:
llvm/trunk/lib/VMCore/ConstantFold.cpp
Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=40125&r1=40124&r2=40125&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/ConstantFold.cpp (original)
+++ llvm/trunk/lib/VMCore/ConstantFold.cpp Fri Jul 20 17:09:02 2007
@@ -140,8 +140,13 @@
const Type *DestTy) {
const Type *SrcTy = V->getType();
- if (isa<UndefValue>(V))
+ if (isa<UndefValue>(V)) {
+ // zext(undef) = 0, because the top bits will be zero.
+ // sext(undef) = 0, because the top bits will all be the same.
+ if (opc == Instruction::ZExt || opc == Instruction::SExt)
+ return Constant::getNullValue(DestTy);
return UndefValue::get(DestTy);
+ }
// If the cast operand is a constant expression, there's a few things we can
// do to try to simplify it.
More information about the llvm-commits
mailing list