This is an archive of the discontinued LLVM Phabricator instance.

[JumpThread] Try to fold SwitchInst before attempting to jumpthread it
Needs ReviewPublic

Authored by trentxintong on Mar 7 2017, 11:35 AM.

Details

Reviewers
efriedma
sanjoy
Summary

Try to fold SwitchInst before attempting to jumpthread it.

Event Timeline

trentxintong created this revision.Mar 7 2017, 11:35 AM

Do not call getPredicateAt when its not a foldable terminator.

efriedma added inline comments.Mar 7 2017, 11:41 AM
test/Transforms/JumpThreading/basic.ll
21 ↗(On Diff #90901)

IIRC, SimplifyCFG converts a switch on i1 to a conditional branch. Given that, I can't see how you could ever trigger this in practice.

efriedma is right about simplifycfg converting switch(i1) to condbr. so this patch is now
a comment change =).

efriedma added inline comments.Mar 7 2017, 12:29 PM
lib/Transforms/Scalar/JumpThreading.cpp
810

I think the original comment was suggesting that jump threading could use getConstantRange or something like that to prune impossible switch destinations.

sanjoy resigned from this revision.Jan 29 2022, 5:34 PM