[llvm] r353911 - [LoopSimplifyCFG] Re-enable const branch folding by default

Maxim Kazantsev via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 20 23:40:42 PST 2019


Hi,

Actually, I’m not. I’m not well familiar with MSSA at all. Just looking into MergeBlockIntoPredecessor, there we do MSSA update after we apply updates to DomTree. I’ll take a bit more digging into it, maybe the way how we update it now is entirely wrong.

I’ll prepare a patch that makes updates in sync to avoid potential problems of this type in the future.

--Nax

From: Alina Sbirlea <alina.sbirlea at gmail.com>
Sent: Thursday, February 21, 2019 1:12 PM
To: Maxim Kazantsev <max.kazantsev at azul.com>
Cc: rtereshin at apple.com; dberlin at dberlin.org; llvm-commits <llvm-commits at lists.llvm.org>; asbirlea at google.com
Subject: Re: [llvm] r353911 - [LoopSimplifyCFG] Re-enable const branch folding by default

Are you sure your update is complete?
It should theoretically match the DT update, i.e. include insert edges not just the delete. All updates should be done together using the same list of updates used for DT, and an up to date DT (see MSSAU->applyUpdates(DTUpdates, DT)).

On Wed, Feb 20, 2019 at 9:53 PM Maxim Kazantsev via llvm-commits <llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>> wrote:
Should be fixed by https://reviews.llvm.org/rL354547

From: Maxim Kazantsev
Sent: Thursday, February 21, 2019 11:49 AM
To: 'rtereshin at apple.com<mailto:rtereshin at apple.com>' <rtereshin at apple.com<mailto:rtereshin at apple.com>>
Cc: llvm-commits <llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>>; dberlin at dberlin.org<mailto:dberlin at dberlin.org>; asbirlea at google.com<mailto:asbirlea at google.com>
Subject: RE: [llvm] r353911 - [LoopSimplifyCFG] Re-enable const branch folding by default

Hi Roman,

Thanks for notification! I’ll fix it asap.

--Max

From: rtereshin at apple.com<mailto:rtereshin at apple.com> <rtereshin at apple.com<mailto:rtereshin at apple.com>>
Sent: Thursday, February 21, 2019 10:25 AM
To: Maxim Kazantsev <max.kazantsev at azul.com<mailto:max.kazantsev at azul.com>>
Cc: llvm-commits <llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>>; dberlin at dberlin.org<mailto:dberlin at dberlin.org>; asbirlea at google.com<mailto:asbirlea at google.com>
Subject: Re: [llvm] r353911 - [LoopSimplifyCFG] Re-enable const branch folding by default

Hi Max,

Looks like this doesn’t collaborate with MemorySSA very well:

./bin/opt -loop-simplifycfg loop-simplifycfg-term-folding-AND-mssa-loop-dependency.ll -enable-mssa-loop-dependency=true -verify-memoryssa=true -enable-loop-simplifycfg-term-folding=true -S -o -
Assertion failed: (find(predecessors(&B), Phi->getIncomingBlock(I)) != pred_end(&B) && "Incoming phi block not a block predecessor"), function verifyDefUses, file ../lib/Analysis/MemorySSA.cpp, line 1947.

The IR is:

define void @main() {
entry:
  br label %for.body

for.body:                                         ; preds = %exit, %entry
  br label %switch.bb<http://switch.bb>

switch.bb<http://switch.bb>:                                        ; preds = %for.body
  switch i2 1, label %default.bb<http://default.bb> [
    i2 1, label %case.bb<http://case.bb>
  ]

case.bb<http://case.bb>:                                          ; preds = %switch
  br label %exit

default.bb<http://default.bb>:                                       ; preds = %switch
  unreachable

exit:                                             ; preds = %case.bb<http://case.bb>
  call void @foo()
  br label %for.body
}

declare void @foo()


Thanks,
Roman


> On Feb 12, 2019, at 10:12 PM, Max Kazantsev via llvm-commits <llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>> wrote:
>
> Author: mkazantsev
> Date: Tue Feb 12 22:12:48 2019
> New Revision: 353911
>
> URL: http://llvm.org/viewvc/llvm-project?rev=353911&view=rev
> Log:
> [LoopSimplifyCFG] Re-enable const branch folding by default
>
> Known underlying bugs have been fixed, intensive fuzz testing did not
> find any new problems. Re-enabling by default. Feel free to revert if
> it causes any functional failures.
>
> Modified:
>    llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
>
> Modified: llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp?rev=353911&r1=353910&r2=353911&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp Tue Feb 12 22:12:48 2019
> @@ -41,7 +41,7 @@ using namespace llvm;
> #define DEBUG_TYPE "loop-simplifycfg"
>
> static cl::opt<bool> EnableTermFolding("enable-loop-simplifycfg-term-folding",
> -                                       cl::init(false));
> +                                       cl::init(true));
>
> STATISTIC(NumTerminatorsFolded,
>           "Number of terminators folded to unconditional branches");
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
_______________________________________________
llvm-commits mailing list
llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190221/3a67d4c5/attachment.html>


More information about the llvm-commits mailing list