[llvm-commits] [llvm] r121860 - /llvm/trunk/lib/Analysis/InstructionSimplify.cpp

Duncan Sands baldrick at free.fr
Wed Dec 15 03:02:22 PST 2010


Author: baldrick
Date: Wed Dec 15 05:02:22 2010
New Revision: 121860

URL: http://llvm.org/viewvc/llvm-project?rev=121860&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/Analysis/InstructionSimplify.cpp

Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=121860&r1=121859&r2=121860&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Wed Dec 15 05:02:22 2010
@@ -441,7 +441,7 @@
 
   // 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 @@
 
   /// 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





More information about the llvm-commits mailing list