This is an archive of the discontinued LLVM Phabricator instance.

Default lowering for experimental.widenable.condition
ClosedPublic

Authored by mkazantsev on Dec 27 2018, 1:32 AM.

Details

Summary

Introduces a pass that provides default lowering strategy for the
experimental.widenable.condition intrinsic, replacing all its uses with i1 true.

Diff Detail

Repository
rL LLVM

Event Timeline

mkazantsev created this revision.Dec 27 2018, 1:32 AM
mkazantsev edited the summary of this revision. (Show Details)Dec 27 2018, 1:33 AM

Why not do this as either a) SelectionDAG or b) CodeGenPrepare? I don't see the value in having the separate pass for this.

reames requested changes to this revision.Jan 16 2019, 5:37 PM

Per previous comments.

This revision now requires changes to proceed.Jan 16 2019, 5:37 PM

Because we might want to get rid of widenable conditions (and therefore of guards) not right before codegen, but earlier? For example, before vectorization to get rid of control flow inside a loop.

reames accepted this revision.Jan 30 2019, 2:15 PM

Because we might want to get rid of widenable conditions (and therefore of guards) not right before codegen, but earlier? For example, before vectorization to get rid of control flow inside a loop.

Max and I discussed offline. We decided on a "let's do both" approach. We want standard codegen to know how to lower guards, but we also want to be able to experiment easily with doing so earlier in the pipeline.

I've posted https://reviews.llvm.org/D56096 which does the same transform in CGP. We could have just scheduled the extra pass, but doing so seemed slightly ugly when CGP would be obviously the right place for this if we didn't also want the option to lower early.

Given that, LGTM.

lib/Transforms/Scalar/LowerWidenableCondition.cpp
65 ↗(On Diff #179539)

At some point down the line, we'll probably want to simplify the CFG here, but that's definitely okay to be a followup.

This revision is now accepted and ready to land.Jan 30 2019, 2:15 PM
mkazantsev marked an inline comment as done.Jan 30 2019, 9:46 PM
mkazantsev added inline comments.
lib/Transforms/Scalar/LowerWidenableCondition.cpp
65 ↗(On Diff #179539)

Not sure if it's worth doing. The typical use case is br i1 some_cond & WC, label1, label2; we only have CFG update if we have previously proved that some_cond is trivially true. If it's a frequent situation in practice, we can think about it.

This revision was automatically updated to reflect the committed changes.