This is an archive of the discontinued LLVM Phabricator instance.

Avoid skipping instructions in IndVarSimplify::sinkUnusedInvariants
Needs ReviewPublic

Authored by rmorylev on Feb 6 2017, 7:35 PM.
This revision needs review, but all reviewers have resigned.

Details

Reviewers
sanjoy
Summary

Fix a bug when every second instruction wasn't sinked because the iterator was incremented over it

Diff Detail

Repository
rL LLVM

Event Timeline

rmorylev created this revision.Feb 6 2017, 7:35 PM
rmorylev added inline comments.Feb 6 2017, 7:39 PM
lib/Transforms/Scalar/IndVarSimplify.cpp
2290

At the end of the loop I is pointing at the next instruction to consider, so this decrement will skip it

test/Transforms/IndVarSimplify/sink-all.ll
23

Verify that all 3 instructions from preheader are sinked

sanjoy requested changes to this revision.Feb 8 2017, 10:29 PM
sanjoy added inline comments.
lib/Transforms/Scalar/IndVarSimplify.cpp
2344

I'd instead do this change as:

  • Remove the isa<DbgInfoIntrinsic>(I) related complexity here (i.e. lines 2344-2354, and the if (Done) break; bits), since we check for DbgInfoIntrinsic and continue over them anyway.
  • Do I++ right after Instruction *ToMove = &*I;.

This would make the entry invariant into the loop "I points to one past the instruction we want to sink", and the I-- in the beginning of the loop body would do the right thing.

This revision now requires changes to proceed.Feb 8 2017, 10:29 PM
rmorylev added inline comments.Feb 9 2017, 10:49 AM
lib/Transforms/Scalar/IndVarSimplify.cpp
2344

Agree. I was just trying to make the patch simple.

sanjoy resigned from this revision.Jan 29 2022, 5:27 PM
This revision now requires review to proceed.Jan 29 2022, 5:27 PM