[llvm] r350117 - Temporarily disable term folding in LoopSimplifyCFG, add tests

Mikael Holmén via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 28 01:38:31 PST 2018


Hi Max,

I found another case that you might want to look at before enabling this 
again. I noticed that:

  opt -S -o - bbi-22646.ll -loop-simplifycfg -licm

crashes with

opt: ../lib/Transforms/Scalar/LICM.cpp:276: bool (anonymous 
namespace)::LoopInvariantCodeMotion::runOnLoop(llvm::Loop *, 
AliasAnalysis *, llvm::LoopInfo *, llvm::DominatorTree *, 
llvm::TargetLibraryInfo *, llvm::TargetTransformInfo *, 
llvm::ScalarEvolution *, llvm::MemorySSA *, 
llvm::OptimizationRemarkEmitter *, bool): Assertion `L->isLCSSAForm(*DT) 
&& "Loop is not in LCSSA form."' failed.

The crash goes away with this patch where you disabled the term folding.

/Mikael

On 12/28/18 7:22 AM, Max Kazantsev via llvm-commits wrote:
> Author: mkazantsev
> Date: Thu Dec 27 22:22:39 2018
> New Revision: 350117
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=350117&view=rev
> Log:
> Temporarily disable term folding in LoopSimplifyCFG, add tests
> 
> Modified:
>      llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
>      llvm/trunk/test/Transforms/LoopSimplifyCFG/constant-fold-branch.ll
> 
> Modified: llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp?rev=350117&r1=350116&r2=350117&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp Thu Dec 27 22:22:39 2018
> @@ -42,7 +42,7 @@ using namespace llvm;
>   #define DEBUG_TYPE "loop-simplifycfg"
>   
>   static cl::opt<bool> EnableTermFolding("enable-loop-simplifycfg-term-folding",
> -                                       cl::init(true));
> +                                       cl::init(false));
>   
>   STATISTIC(NumTerminatorsFolded,
>             "Number of terminators folded to unconditional branches");
> 
> Modified: llvm/trunk/test/Transforms/LoopSimplifyCFG/constant-fold-branch.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopSimplifyCFG/constant-fold-branch.ll?rev=350117&r1=350116&r2=350117&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/LoopSimplifyCFG/constant-fold-branch.ll (original)
> +++ llvm/trunk/test/Transforms/LoopSimplifyCFG/constant-fold-branch.ll Thu Dec 27 22:22:39 2018
> @@ -1,4 +1,7 @@
>   ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
> +; XFAIL: *
> +; Tests complex_dead_subloop_branch and complex_dead_subloop_switch fail an
> +; assertion, therefore the CFG simplification is temporarily disabled.
>   ; REQUIRES: asserts
>   ; RUN: opt -S -enable-loop-simplifycfg-term-folding=true -loop-simplifycfg -debug-only=loop-simplifycfg -verify-loop-info -verify-dom-info -verify-loop-lcssa 2>&1 < %s | FileCheck %s
>   ; RUN: opt -S -enable-loop-simplifycfg-term-folding=true -passes='require<domtree>,loop(simplify-cfg)' -debug-only=loop-simplifycfg -verify-loop-info -verify-dom-info -verify-loop-lcssa 2>&1 < %s | FileCheck %s
> @@ -2507,3 +2510,59 @@ loop_1_backedge:
>   exit:
>     ret i32 %i
>   }
> +
> +define i32 @complex_dead_subloop_branch(i1 %cond1, i1 %cond2, i1 %cond3) {
> +entry:
> +  br label %loop
> +
> +loop:
> +  br i1 true, label %latch, label %subloop
> +
> +subloop:
> +  br i1 %cond1, label %x, label %y
> +
> +x:
> +  br label %subloop_latch
> +
> +y:
> +  br label %subloop_latch
> +
> +subloop_latch:
> +  %dead_phi = phi i32 [ 1, %x ], [ 2, %y ]
> +  br i1 %cond2, label %latch, label %subloop
> +
> +latch:
> +  %result = phi i32 [ 0, %loop ], [ %dead_phi, %subloop_latch ]
> +  br i1 %cond3, label %loop, label %exit
> +
> +exit:
> +  ret i32 %result
> +}
> +
> +define i32 @complex_dead_subloop_switch(i1 %cond1, i1 %cond2, i1 %cond3) {
> +entry:
> +  br label %loop
> +
> +loop:
> +  switch i32 1, label %latch [ i32 0, label %subloop ]
> +
> +subloop:
> +  br i1 %cond1, label %x, label %y
> +
> +x:
> +  br label %subloop_latch
> +
> +y:
> +  br label %subloop_latch
> +
> +subloop_latch:
> +  %dead_phi = phi i32 [ 1, %x ], [ 2, %y ]
> +  br i1 %cond2, label %latch, label %subloop
> +
> +latch:
> +  %result = phi i32 [ 0, %loop ], [ %dead_phi, %subloop_latch ]
> +  br i1 %cond3, label %loop, label %exit
> +
> +exit:
> +  ret i32 %result
> +}
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bbi-22646.ll
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181228/16e91b96/attachment.ksh>


More information about the llvm-commits mailing list