diff options
author | Duncan Sands <baldrick@free.fr> | 2010-12-15 11:02:22 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2010-12-15 11:02:22 +0000 |
commit | f8b1a5ea9602bb65a5cf59d3d34f2851a08cdc3e (patch) | |
tree | 84b2278fe9881c470e4caacd102f786ab0952be0 /lib/Analysis/InstructionSimplify.cpp | |
parent | 26e097ca4bdb31000655ff9ec39fe7d9b7ea226d (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121860 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/InstructionSimplify.cpp')
-rw-r--r-- | lib/Analysis/InstructionSimplify.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp index 87125191ad..75734e8770 100644 --- a/lib/Analysis/InstructionSimplify.cpp +++ b/lib/Analysis/InstructionSimplify.cpp @@ -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 |