[llvm] r278929 - Revert "[Reassociate] Avoid iterator invalidation when negating value."

Chad Rosier via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 17 07:31:35 PDT 2016


Author: mcrosier
Date: Wed Aug 17 09:31:34 2016
New Revision: 278929

URL: http://llvm.org/viewvc/llvm-project?rev=278929&view=rev
Log:
Revert "[Reassociate] Avoid iterator invalidation when negating value."

This reverts commit r278928 due to lit test failures.

Removed:
    llvm/trunk/test/Transforms/Reassociate/invalid-iterator.ll
Modified:
    llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp?rev=278929&r1=278928&r2=278929&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Wed Aug 17 09:31:34 2016
@@ -842,13 +842,6 @@ static Value *NegateValue(Value *V, Inst
     if (TheNeg->getParent()->getParent() != BI->getParent()->getParent())
       continue;
 
-    // Don't move the negate if it's in the block we're currently optimizing as
-    // this may invalidate our iterator.
-    // FIXME: We should find a more robust solution as we're missing local CSE
-    // opportunities because of this constraint.
-    if (TheNeg->getParent() == BI->getParent())
-      continue;
-
     BasicBlock::iterator InsertPt;
     if (Instruction *InstInput = dyn_cast<Instruction>(V)) {
       if (InvokeInst *II = dyn_cast<InvokeInst>(InstInput)) {
@@ -1870,8 +1863,6 @@ void ReassociatePass::RecursivelyEraseDe
 /// Zap the given instruction, adding interesting operands to the work list.
 void ReassociatePass::EraseInst(Instruction *I) {
   assert(isInstructionTriviallyDead(I) && "Trivially dead instructions only!");
-  DEBUG(dbgs() << "Erasing dead inst: "; I->dump());
-
   SmallVector<Value*, 8> Ops(I->op_begin(), I->op_end());
   // Erase the dead instruction.
   ValueRankMap.erase(I);

Removed: llvm/trunk/test/Transforms/Reassociate/invalid-iterator.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Reassociate/invalid-iterator.ll?rev=278928&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/Reassociate/invalid-iterator.ll (original)
+++ llvm/trunk/test/Transforms/Reassociate/invalid-iterator.ll (removed)
@@ -1,30 +0,0 @@
-; RUN: opt < %s -reassociate -die -S | FileCheck %s
-
-; PR28367
-; Check to make sure %sub2 isn't moved from for.body.  Doing so would invalidate
-; the iterator.
-
-; CHECK-LABEL: @fn1
-; CHECK: for.body:
-; CHECK-NEXT:   %sub2 = sub nsw i32 0, %d.0
-; CHECK-NEXT:   store i32 %sub2, i32* %ptr, align 4
-define void @fn1(i32 %a, i1 %c, i32* %ptr)  {
-entry:
-  br label %for.cond
-
-for.cond:
-  %d.0 = phi i32 [ 1, %entry ], [ 2, %for.body ]
-  br i1 %c, label %for.end, label %for.body
-
-for.body:
-  %sub1 = sub i32 %a, %d.0
-  %dead1 = add i32 %sub1, 1
-  %dead2 = mul i32 %dead1, 3
-  %dead3 = mul i32 %dead2, %sub1
-  %sub2 = sub nsw i32 0, %d.0
-  store i32 %sub2, i32* %ptr, align 4
-  br label %for.cond
-
-for.end:
-  ret void
-}




More information about the llvm-commits mailing list