Home | History | Annotate | Download | only in LoopUnswitch
      1 ; RUN: opt -loop-unswitch -disable-output -stats -info-output-file - < %s | FileCheck --check-prefix=STATS %s
      2 ; RUN: opt -loop-unswitch -simplifycfg -S < %s | FileCheck %s
      3 ; PR5373
      4 
      5 ; Loop unswitching shouldn't trivially unswitch the true case of condition %a
      6 ; in the code here because it leads to an infinite loop. While this doesn't
      7 ; contain any instructions with side effects, it's still a kind of side effect.
      8 ; It can trivially unswitch on the false cas of condition %a though.
      9 
     10 ; STATS: 2 loop-unswitch - Number of branches unswitched
     11 ; STATS: 1 loop-unswitch - Number of unswitches that are trivial
     12 
     13 ; CHECK: @func_16
     14 ; CHECK-NEXT: entry:
     15 ; CHECK-NEXT: br i1 %a, label %entry.split, label %abort0.split
     16 
     17 ; CHECK: entry.split:
     18 ; CHECK-NEXT: br i1 %b, label %cond.end.us, label %abort1
     19 
     20 ; CHECK: cond.end.us:
     21 ; CHECK-NEXT: br label %cond.end.us
     22 
     23 ; CHECK: abort0.split:
     24 ; CHECK-NEXT: call void @end0() noreturn nounwind
     25 ; CHECK-NEXT: unreachable
     26 
     27 ; CHECK: abort1:
     28 ; CHECK-NEXT: call void @end1() noreturn nounwind
     29 ; CHECK-NEXT: unreachable
     30 
     31 ; CHECK: }
     32 
     33 define void @func_16(i1 %a, i1 %b) nounwind {
     34 entry:
     35   br label %for.body
     36 
     37 for.body:
     38   br i1 %a, label %cond.end, label %abort0
     39 
     40 cond.end:
     41   br i1 %b, label %for.body, label %abort1
     42 
     43 abort0:
     44   call void @end0() noreturn nounwind
     45   unreachable
     46 
     47 abort1:
     48   call void @end1() noreturn nounwind
     49   unreachable
     50 }
     51 
     52 declare void @end0() noreturn
     53 declare void @end1() noreturn
     54