Home | History | Annotate | Download | only in IndVarSimplify
      1 ; RUN: opt -S -loop-unswitch -instcombine -indvars < %s | FileCheck %s
      2 
      3 ; This used to crash in SCEVExpander when there were congruent phis with and
      4 ; undef incoming value from the loop header. The -loop-unswitch -instcombine is
      5 ; necessary to create just this pattern, which is essentially a nop and gets
      6 ; folded away aggressively if spelled out in IR directly.
      7 ; PR 20093
      8 
      9 @c = external global i32**, align 8
     10 
     11 define void @test1() {
     12 entry:
     13   br i1 undef, label %for.end12, label %for.cond.preheader
     14 
     15 for.cond.preheader:                               ; preds = %entry
     16   %0 = load i32**, i32*** @c, align 8
     17   %1 = load i32*, i32** %0, align 8
     18   %2 = load i32, i32* %1, align 4
     19   br label %for.body
     20 
     21 for.body:                                         ; preds = %for.cond.backedge, %for.body9.us, %for.cond.preheader
     22   %3 = phi i32* [ %1, %for.cond.preheader ], [ %3, %for.cond.backedge ], [ %6, %for.body9.us ]
     23   %4 = phi i32 [ %2, %for.cond.preheader ], [ undef, %for.cond.backedge ], [ %7, %for.body9.us ]
     24   %i.024 = phi i32 [ 0, %for.cond.preheader ], [ %inc, %for.cond.backedge ], [ 0, %for.body9.us ]
     25   %tobool1 = icmp eq i32 %4, 0
     26   br i1 %tobool1, label %if.end, label %for.cond.backedge
     27 
     28 if.end:                                           ; preds = %for.body
     29   %5 = load i32, i32* %3, align 4
     30   %tobool4 = icmp eq i32 %5, 0
     31   br i1 %tobool4, label %for.cond3, label %for.body9.preheader
     32 
     33 for.body9.preheader:                              ; preds = %if.end
     34   %tobool8 = icmp eq i32 %i.024, 1
     35   br i1 %tobool8, label %for.body9.us, label %for.body9
     36 
     37 for.body9.us:                                     ; preds = %for.body9.preheader
     38   %6 = load i32*, i32** undef, align 8
     39   %7 = load i32, i32* %6, align 4
     40   br label %for.body
     41 
     42 for.cond3:                                        ; preds = %for.cond3, %if.end
     43   br label %for.cond3
     44 
     45 for.body9:                                        ; preds = %for.body9, %for.body9.preheader
     46   br label %for.body9
     47 
     48 for.cond.backedge:                                ; preds = %for.body
     49   %inc = add nsw i32 %i.024, 1
     50   br i1 false, label %for.body, label %for.end12
     51 
     52 for.end12:                                        ; preds = %for.cond.backedge, %entry
     53   ret void
     54 
     55 ; CHECK-LABEL: @test1
     56 ; CHECK-NOT: phi
     57 }
     58