This is an archive of the discontinued LLVM Phabricator instance.

[SCEV] Try smaller ZExts when using loop guard info.
ClosedPublic

Authored by fhahn on May 3 2023, 2:23 PM.

Details

Summary

If we didn't find the extact ZExt expr in the rewrite map, check if
there's an entry for a smaller ZExt we can use instead.

Diff Detail

Event Timeline

fhahn created this revision.May 3 2023, 2:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 3 2023, 2:23 PM
fhahn requested review of this revision.May 3 2023, 2:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 3 2023, 2:23 PM
mkazantsev added inline comments.May 4 2023, 9:15 PM
llvm/lib/Analysis/ScalarEvolution.cpp
14941

If Bitwidth is 8 * 9 = 72, at some point you will end up with BitWidth = 9 and enter this loop, and then on division you will lose a meaningful last bit. Was it your intention?

I think Bitwidth % 8 == 0 thingy should be in while loop.

fhahn updated this revision to Diff 519777.May 5 2023, 2:08 AM

Move % 8 check into loop cond as suggested, thanks!

fhahn marked an inline comment as done.May 5 2023, 2:08 AM
fhahn added inline comments.
llvm/lib/Analysis/ScalarEvolution.cpp
14941

Thanks, updated!

fhahn marked an inline comment as done.May 30 2023, 8:55 AM

ping :)

nikic accepted this revision.Jun 7 2023, 1:25 PM

LGTM

This revision is now accepted and ready to land.Jun 7 2023, 1:25 PM
This revision was landed with ongoing or failed builds.Jun 9 2023, 12:06 PM
This revision was automatically updated to reflect the committed changes.