This is an archive of the discontinued LLVM Phabricator instance.

[EarlyCSE] Simplify guard intrinsics
ClosedPublic

Authored by sanjoy on Apr 26 2016, 7:58 PM.

Details

Summary

This change teaches EarlyCSE some basic properties of guard intrinsics:

  • Guard intrinsics read all memory, but don't write to any memory
  • After a guard has executed, the condition it was guarding on can be assumed to be true
  • Guard intrinsics on a constant true are no-ops

Diff Detail

Event Timeline

sanjoy updated this revision to Diff 55158.Apr 26 2016, 7:58 PM
sanjoy retitled this revision from to [EarlyCSE] Simplify guard intrinsics.
sanjoy updated this object.
sanjoy added reviewers: reames, hfinkel.
sanjoy added a subscriber: llvm-commits.
majnemer added inline comments.
lib/Transforms/Scalar/EarlyCSE.cpp
560

Any reason against using m_One here?

sanjoy updated this revision to Diff 55160.Apr 26 2016, 9:21 PM
sanjoy marked an inline comment as done.
  • Address review
reames accepted this revision.Apr 29 2016, 2:09 PM
reames edited edge metadata.

LGTM w/minor comments.

lib/Transforms/Scalar/EarlyCSE.cpp
561

You should consider (as a future change) moving this into isInstructionTriviallyDead.

test/Transforms/EarlyCSE/guards.ll
26

If you used a sub here, you could check for ret i32 0

45

I'd suggest splitting this into two test cases.

This revision is now accepted and ready to land.Apr 29 2016, 2:09 PM
This revision was automatically updated to reflect the committed changes.
sanjoy marked 2 inline comments as done.