This is an archive of the discontinued LLVM Phabricator instance.

[SimpleLoopUnswitch] Canonicalize conditions for injection of invariant condition
ClosedPublic

Authored by mkazantsev on Feb 2 2023, 5:52 AM.

Details

Summary

When loop condition isn't immediately in the form supported by invariant injection
unswitching, try to canonicalize it to this form.

Diff Detail

Event Timeline

mkazantsev created this revision.Feb 2 2023, 5:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 2 2023, 5:52 AM
mkazantsev requested review of this revision.Feb 2 2023, 5:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 2 2023, 5:52 AM

The patch itself seems straightforward. LGTM.

llvm/test/Transforms/SimpleLoopUnswitch/inject-invariant-conditions.ll
375–389

This seems unlikely profitable... Why not max from -2147483648 and [[LEN]]?

Or do I miss anything?

skatkov added inline comments.Feb 15 2023, 1:22 AM
llvm/test/Transforms/SimpleLoopUnswitch/inject-invariant-conditions.ll
375–389

min I meant.

skatkov accepted this revision.Feb 15 2023, 2:24 AM
This revision is now accepted and ready to land.Feb 15 2023, 2:24 AM
mkazantsev added inline comments.Feb 15 2023, 2:26 AM
llvm/test/Transforms/SimpleLoopUnswitch/inject-invariant-conditions.ll
375–389

It's just a confusing name, I'll rename it. In fact, it is profitable when len <s 0. If you look at test_04 which is the aim of this whole thing, it should make it more clear.

This revision was landed with ongoing or failed builds.Feb 15 2023, 3:24 AM
This revision was automatically updated to reflect the committed changes.