If we detect that the instruction we are simplifying is unreachable, arrange for

it to be replaced by undef rather than not replaced at all, the idea being that
this may reduce the amount of work done by whoever called InstructionSimplify.

llvm-svn: 121860
This commit is contained in:
Duncan Sands 2010-12-15 11:02:22 +00:00
parent 3d1803495e
commit 019a418808
1 changed files with 3 additions and 3 deletions

View File

@ -441,7 +441,7 @@ static Value *SimplifyXorInst(Value *Op0, Value *Op1, const TargetData *TD,
// A ^ undef -> undef
if (isa<UndefValue>(Op1))
return UndefValue::get(Op0->getType());
return Op1;
// A ^ 0 = A
if (match(Op1, m_Zero()))
@ -868,8 +868,8 @@ Value *llvm::SimplifyInstruction(Instruction *I, const TargetData *TD,
/// If called on unreachable code, the above logic may report that the
/// instruction simplified to itself. Make life easier for users by
/// detecting that case here, returning null if it occurs.
return Result == I ? 0 : Result;
/// detecting that case here, returning a safe value instead.
return Result == I ? UndefValue::get(I->getType()) : Result;
}
/// ReplaceAndSimplifyAllUses - Perform From->replaceAllUsesWith(To) and then