This is an archive of the discontinued LLVM Phabricator instance.

[GuardWidening] Widen widenable conditions instead of branches
AbandonedPublic

Authored by aleksandr.popov on Aug 11 2023, 8:36 AM.

Details

Summary

Change GuardWidening scheme from branches widening when we always
maintain br(cond && WC) form:

%wc = call i1 @widenable.condition()
%guard = and i1 %cond0, %wc
br i1 %guard ...
-->
%wide.check = and i1 %cond0, %cond1
%wc = call i1 @widenable.condition()
%guard = and i1 %%wide.check, %wc
br i1 %guard ...

...to widenable conditions widening when we replace WC by
(NewCheck && WC):

%wc = call i1 @widenable.condition()
%guard = and i1 %cond0, %wc
br i1 %guard ...
-->
%wc = call i1 @widenable.condition()
%wide.check = and i1 %cond1, %wc
%guard = and i1 %cond0, %wide.check
br i1 %guard ...

It is necessary to avoid cases when we turn loop-invarinat branch to
a loop-variant one, like in this issue:
https://github.com/llvm/llvm-project/issues/60234

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2023, 8:36 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
aleksandr.popov requested review of this revision.Aug 11 2023, 8:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2023, 8:36 AM
anna added a subscriber: anna.Aug 17 2023, 7:57 AM

do you need review for this? Could you pls state the review stack in the description so it is clear the order of reviews. Thanks.

anna requested changes to this revision.Sep 5 2023, 2:03 PM

Rebase needed. thanks.

llvm/lib/Transforms/Scalar/GuardWidening.cpp
292–295

Pls rebase. This was changed to return the optional result.

This revision now requires changes to proceed.Sep 5 2023, 2:03 PM