ConstantFold, InstSimplify: undef >>a x can be either -1 or 0, choose 0

Zero is usually a nicer constant to have than -1.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223969 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer
2014-12-10 21:58:15 +00:00
parent ea9bcfc707
commit 72c6bdbf70
3 changed files with 7 additions and 6 deletions

View File

@@ -960,8 +960,9 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
// X >>a undef -> undef
if (isa<UndefValue>(C2))
return C2;
// undef >>a X -> all ones
return Constant::getAllOnesValue(C1->getType());
// TODO: undef >>a X -> undef if the shift is exact
// undef >>a X -> 0
return Constant::getNullValue(C1->getType());
case Instruction::Shl:
// X << undef -> undef
if (isa<UndefValue>(C2))