This is an archive of the discontinued LLVM Phabricator instance.

[SCEVExpand] Only create required predicate checks.
ClosedPublic

Authored by fhahn on Jan 6 2022, 7:47 AM.

Details

Summary

Currently generateOverflowCheck always creates code for Step being
negative and positive, followed by a select at the end depending on
Step's sign.

This patch updates the code to only create either the checks for step
being positive or negative, if the sign is known.

Follow-up to D116696.

Diff Detail

Event Timeline

fhahn created this revision.Jan 6 2022, 7:47 AM
fhahn requested review of this revision.Jan 6 2022, 7:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 6 2022, 7:47 AM
reames requested changes to this revision.Jan 6 2022, 7:55 AM
reames added inline comments.
llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
2520

These checks seem redundant. You should be able to use !isKnownNegative and !isKnownPositive unless I'm missing something?

This revision now requires changes to proceed.Jan 6 2022, 7:55 AM
fhahn updated this revision to Diff 397924.Jan 6 2022, 10:03 AM

Simplified sign check as suggested, thanks!

fhahn marked an inline comment as done.Jan 6 2022, 10:04 AM
fhahn added inline comments.
llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
2520

Thanks, I simplified the checks!

reames accepted this revision.Jan 6 2022, 10:19 AM

LGTM

This revision is now accepted and ready to land.Jan 6 2022, 10:19 AM
fhahn updated this revision to Diff 398098.Jan 7 2022, 4:11 AM
fhahn marked an inline comment as done.

rebase to trigger another precommit test run

fhahn updated this revision to Diff 398113.Jan 7 2022, 5:44 AM

another rebase to trigger tests

This revision was landed with ongoing or failed builds.Jan 7 2022, 6:50 AM
This revision was automatically updated to reflect the committed changes.