[llvm] r270944 - ValueMapper: fix typo in minor optimization on constant mapping (NFC)

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Thu May 26 17:32:13 PDT 2016


Author: mehdi_amini
Date: Thu May 26 19:32:12 2016
New Revision: 270944

URL: http://llvm.org/viewvc/llvm-project?rev=270944&view=rev
Log:
ValueMapper: fix typo in minor optimization on constant mapping (NFC)

If every operands of a constant are mapping to themselves, and the
type does not change, we have an early exit as acknowledged in the
comment:

  // Otherwise, we have some other constant to remap.  Start by checking to see
  // if all operands have an identity remapping.

However instead of checking for identity the code was checking if the
operands were mapped to the constant itself, which is rarely true.

As a consequence, the coverage report showed that the early exit was
never taken.

Modified:
    llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp

Modified: llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp?rev=270944&r1=270943&r2=270944&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp Thu May 26 19:32:12 2016
@@ -436,7 +436,8 @@ Value *Mapper::mapValue(const Value *V)
   for (; OpNo != NumOperands; ++OpNo) {
     Value *Op = C->getOperand(OpNo);
     Mapped = mapValue(Op);
-    if (Mapped != C) break;
+    if (Mapped != Op)
+      break;
   }
 
   // See if the type mapper wants to remap the type as well.




More information about the llvm-commits mailing list