From ae707582c024e5db30f13d3fc3a7f21e72c4bc18 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Wed, 10 Dec 2014 09:14:52 +0000 Subject: InstSimplify: [al]shr exact undef, %X -> undef Exact shifts always keep the non-zero bits of their input. This means it keeps it's undef bits. llvm-svn: 223923 --- llvm/lib/Analysis/InstructionSimplify.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'llvm/lib') diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 767b42b4bd7..1c5a917cbec 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -1387,8 +1387,10 @@ static Value *SimplifyLShrInst(Value *Op0, Value *Op1, bool isExact, return V; // undef >>l X -> 0 + // undef >>l X -> undef (if it's exact) if (match(Op0, m_Undef())) - return Constant::getNullValue(Op0->getType()); + return isExact ? UndefValue::get(Op0->getType()) + : Constant::getNullValue(Op0->getType()); // (X << A) >> A -> X Value *X; @@ -1421,8 +1423,10 @@ static Value *SimplifyAShrInst(Value *Op0, Value *Op1, bool isExact, return Op0; // undef >>a X -> all ones + // undef >>a X -> undef (if it's exact) if (match(Op0, m_Undef())) - return Constant::getAllOnesValue(Op0->getType()); + return isExact ? UndefValue::get(Op0->getType()) + : Constant::getAllOnesValue(Op0->getType()); // (X << A) >> A -> X Value *X; -- cgit v1.2.3