This is an archive of the discontinued LLVM Phabricator instance.

[SimplifyCFG] avoid creating unnecessary assume calls
AbandonedPublic

Authored by spatel on Feb 23 2021, 9:38 AM.

Details

Summary

We are looking at improving analysis for undef in D97244, but there is concern that extra assumptions created can counteract the benefits.

While looking at the most basic examples, it seems clear that simplifycfg is creating assumes that have no possible benefit because no uses of the incoming values remain after we reduce the control-flow. The usual dead code elimination utils don't try hard to kill assumes, so this can lead to bloat that remains through the optimizer.

This patch tries to avoid creating assumes during branch elimination if there is likely no need for them. This reverses several of the test diffs that were added with D61409, but I added some test comments to show that we do still create assumes where it would be helpful.

Diff Detail

Event Timeline

spatel created this revision.Feb 23 2021, 9:38 AM
spatel requested review of this revision.Feb 23 2021, 9:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 23 2021, 9:38 AM

I think the fact that we are *not* creating such assumes in most of the places is a bug.
I can't really comment on the strain such assumes incur on the optimization pipeline,
but i don't expect it to be too high, and i do think that should be fixed (by assume operand bundles?)
rather than the use case be shunned into a corner and avoided.

Concretely, i would expect that this will pessimize e.g. the case where
we are operating on a function argument, we happen to not have other uses,
so we don't emit an assumption, but then we inline the function
and suddenly there are uses that would have benefitted from that knowledge,
but it has been lost by then..

Yeah, I think that assume bundles should be the thing we want here.

spatel abandoned this revision.Feb 23 2021, 11:46 AM

Ok - I'll abandon this. I think it's ok to try D97244. If we do hit problems, we have a link to this patch for potential solutions.