Home | History | Annotate | Download | only in LoopDeletion
      1 ; RUN: opt -S -analyze -scalar-evolution -loop-deletion -scalar-evolution < %s | FileCheck %s --check-prefix=SCEV-EXPRS
      2 ; RUN: opt -S -loop-deletion < %s | FileCheck %s --check-prefix=IR-AFTER-TRANSFORM
      3 ; RUN: opt -S -indvars -loop-deletion -indvars < %s | FileCheck %s --check-prefix=ORIGINAL-CRASH
      4 
      5 ; Checking for a crash.  Loop-deletion would change the loop
      6 ; disposition of an instruction, but not update SCEV.
      7 
      8 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
      9 target triple = "x86_64-apple-macosx10.11.0"
     10 
     11 define void @pr27570() {
     12 ; IR-AFTER-TRANSFORM-LABEL: @pr27570(
     13 ; ORIGINAL-CRASH: @pr27570(
     14 entry:
     15   br label %for.cond
     16 
     17 for.cond:                                         ; preds = %for.cond14, %entry
     18   %f.0 = phi i32 [ 20, %entry ], [ 0, %for.cond14 ]
     19   br label %for.body
     20 
     21 for.body:                                         ; preds = %for.inc11, %for.cond
     22 ; IR-AFTER-TRANSFORM: for.body:
     23 ; IR-AFTER-TRANSFORM: %cmp = icmp eq i32 %val, -1
     24 ; IR-AFTER-TRANSFORM: %conv7 = zext i1 %cmp to i32
     25 ; IR-AFTER-TRANSFORM: for.body6:
     26 
     27 ; SCEV-EXPRS:  %conv7 = zext i1 %cmp to i32
     28 ; SCEV-EXPRS:  %conv7 = zext i1 %cmp to i32
     29 ; SCEV-EXPRS-NEXT:  -->  {{.*}} LoopDispositions: { %for.body: Variant, %for.cond: Variant, %for.body6: Invariant }
     30   %val = phi i32 [ -20, %for.cond ], [ %inc12, %for.inc11 ]
     31   %g.040 = phi i32 [ -20, %for.cond ], [ %and.lcssa, %for.inc11 ]
     32   br label %for.body6
     33 
     34 for.body6:                                        ; preds = %for.body6, %for.body
     35   %h.039 = phi i32 [ 1, %for.body ], [ %inc, %for.body6 ]
     36   %g.138 = phi i32 [ %g.040, %for.body ], [ %and, %for.body6 ]
     37   %cmp = icmp eq i32 %val, -1
     38   %conv7 = zext i1 %cmp to i32
     39   %add.i = add nsw i32 %conv7, %h.039
     40   %sext = shl i32 %add.i, 24
     41   %conv8 = ashr exact i32 %sext, 24
     42   %cmp9 = icmp eq i32 %conv8, %f.0
     43   %conv10 = zext i1 %cmp9 to i32
     44   %and = and i32 %conv10, %g.138
     45   %inc = add i32 %h.039, 1
     46   br i1 undef, label %for.inc11, label %for.body6
     47 
     48 for.inc11:                                        ; preds = %for.body6
     49   %and.lcssa = phi i32 [ %and, %for.body6 ]
     50   %inc12 = add nsw i32 %val, 1
     51   %tobool = icmp eq i32 %inc12, 0
     52   br i1 %tobool, label %for.cond14, label %for.body
     53 
     54 for.cond14:                                       ; preds = %for.cond14, %for.inc11
     55   br i1 undef, label %for.cond, label %for.cond14
     56 }
     57