This is an archive of the discontinued LLVM Phabricator instance.

[JumpThread] Do RAUW in case Cond folds to a constant in the CFG
ClosedPublic

Authored by trentxintong on Apr 23 2017, 2:41 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

trentxintong created this revision.Apr 23 2017, 2:41 PM

Accidentally removed a few lines.

sanjoy accepted this revision.Apr 24 2017, 6:21 PM

lgtm with nits

lib/Transforms/Scalar/JumpThreading.cpp
1252 ↗(On Diff #96326)

Separately, it may be better to use DenseMapInfo<BasicBlock *>::getTombStoneKey() here.

1322 ↗(On Diff #96326)

I'd structure this as:

if (auto *CondInst = dyn_cast<Instruction>(Cond)) {
  if (CondInst->use_empty()) {
  } else if (OnlyVal && ...) {
  }
}

Another thing is that this code needs to check !CondInst->mayHaveSideEffects() before removing it.

test/Transforms/JumpThreading/fold-not-thread.ll
142 ↗(On Diff #96326)

Please also add a negative test where %add = add i32 %value, 64 is not in L0.

This revision is now accepted and ready to land.Apr 24 2017, 6:21 PM
trentxintong added inline comments.Apr 24 2017, 7:53 PM
lib/Transforms/Scalar/JumpThreading.cpp
1322 ↗(On Diff #96326)

Good catch with the extra check !

Address Comments

This revision was automatically updated to reflect the committed changes.