This is an archive of the discontinued LLVM Phabricator instance.

[SCEV] Avoid creating unnecessary SCEVs for SelectInsts.
ClosedPublic

Authored by fhahn on Jul 13 2022, 9:31 PM.

Details

Summary

After 675080a4533b, we always create SCEVs for all operands of a
SelectInst. This can cause notable compile-time regressions compared to
the recursive algorithm, which only evaluates the operands if the select
is in a form we can create a usable expression.

This approach adds additional logic to getOperandsToCreate to only
queue operands for selects if we will later be able to construct a
usable SCEV.

Unfortunately this introduces a bit of coupling between actual SCEV
construction for selects and getOperandsToCreate, but I am not sure if
there are better alternatives to address the regression mentioned for
675080a4533b.

This doesn't have any notable compile-time impact on CTMark.

Diff Detail

Event Timeline

fhahn created this revision.Jul 13 2022, 9:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2022, 9:31 PM
fhahn requested review of this revision.Jul 13 2022, 9:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2022, 9:31 PM
foad added a subscriber: foad.Jul 13 2022, 10:34 PM
nikic accepted this revision.Jul 14 2022, 12:36 AM

LGTM

I was wondering if we can't drop that code for select -> min/max formation now that we canonicalize to intrinsics, but then I remembered that we still use the select form for pointers.

This revision is now accepted and ready to land.Jul 14 2022, 12:36 AM
foad added a comment.Jul 14 2022, 2:35 AM

I can confirm that this fixes the compile time regression I reported - thanks!

This revision was landed with ongoing or failed builds.Jul 14 2022, 9:24 AM
This revision was automatically updated to reflect the committed changes.