This is an archive of the discontinued LLVM Phabricator instance.

[LV] Model if-converted phi node cost
ClosedPublic

Authored by mssimpso on Apr 10 2017, 2:27 PM.

Details

Summary

Phi nodes in non-header blocks are converted to select instructions after if-conversion. This patch updates the cost model to account for the selects.

Diff Detail

Repository
rL LLVM

Event Timeline

mssimpso created this revision.Apr 10 2017, 2:27 PM
mkuper accepted this revision.Apr 10 2017, 3:10 PM

LGTM

lib/Transforms/Vectorize/LoopVectorize.cpp
7280 ↗(On Diff #94742)

We don't need to handle Phi->getNumIncomingValues() == 0 - it doesn't pass the verifier, right?

7285 ↗(On Diff #94742)

This returns 1 by default, right? I'm not entirely sure that's the right thing to do here, but it's probably no worse than the current state.

test/Transforms/LoopVectorize/phi-cost.ll
7 ↗(On Diff #94742)

Please also add a CHECK for the induction phi.

This revision is now accepted and ready to land.Apr 10 2017, 3:10 PM

Thanks, Michael!

lib/Transforms/Vectorize/LoopVectorize.cpp
7280 ↗(On Diff #94742)

That's right.

7285 ↗(On Diff #94742)

Yes, it returns 1. We went with getCFInstrCost(Instrunction::PHI) when doing the inserts for predicated instructions, so I thought it would be good to be consistent.

test/Transforms/LoopVectorize/phi-cost.ll
7 ↗(On Diff #94742)

Will do.

This revision was automatically updated to reflect the committed changes.