This is an archive of the discontinued LLVM Phabricator instance.

Switch To Select optimization , fixed case with multiple incoming edges from same block
ClosedPublic

Authored by kariddi on Oct 12 2014, 5:00 PM.

Details

Summary

Hello, this is a reattempt to push the Switch To Select optimization for switches with only two cases

This is the fix for this patch http://reviews.llvm.org/D5620 that assumed that PHIs should never have multiple incoming edges from the same block , but even if the IR Verifier enforces this condition, it seems to be not followed in the code in SimplifyCFG where it is actually expected by certain optimizations.

This patch makes sure this code follows that convention as well.

Diff Detail

Event Timeline

kariddi updated this revision to Diff 14779.Oct 12 2014, 5:00 PM
kariddi retitled this revision from to Switch To Select optimization , fixed case with multiple incoming edges from same block.
kariddi updated this object.
kariddi edited the test plan for this revision. (Show Details)
kariddi added reviewers: hans, joerg, Jiangning.
kariddi set the repository for this revision to rL LLVM.
kariddi added a subscriber: Unknown Object (MLST).
kariddi added inline comments.
lib/Transforms/Utils/SimplifyCFG.cpp
3575

This is the only thing that changed from the previous patch, with this becoming a "while" from an "if"

hans edited edge metadata.Oct 13 2014, 11:00 AM

After reading the discussion on the previous commit thread, the description doesn't sound completely accurate. I.e. it seems like multiple edges from a bb to a phi is allowed as long as they have the same value.

lib/Transforms/Utils/SimplifyCFG.cpp
3575

Can you add a test case that covers this?

kariddi updated this revision to Diff 14838.Oct 13 2014, 4:00 PM
kariddi edited edge metadata.

Added a test that uses Joerg code to check that we handle correctly the case with multiple incoming edges for the same block.

lib/Transforms/Utils/SimplifyCFG.cpp
3575

Done! Thanks!

hans accepted this revision.Oct 13 2014, 5:02 PM
hans edited edge metadata.

lgtm

This revision is now accepted and ready to land.Oct 13 2014, 5:02 PM

Thanks, I will push it then.

Please Jiangning and Joerg, if it should break anyone of your workloads and I'm not prompt in response don't hesitate to revert :)

kariddi closed this revision.Oct 13 2014, 7:11 PM

Landed r219656