Home | History | Annotate | Download | only in LoopSimplify
      1 ; RUN: opt -indvars -S %s | FileCheck %s
      2 ;
      3 ; PR18384: ValueHandleBase::ValueIsDeleted.
      4 ;
      5 ; Ensure that LoopSimplify calls ScalarEvolution::forgetLoop before
      6 ; deleting a block, regardless of whether any values were hoisted out
      7 ; of the block.
      8 
      9 target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
     10 target triple = "x86_64-apple-darwin"
     11 
     12 %struct.Params = type { [2 x [4 x [16 x i16]]] }
     13 
     14 ; Verify that the loop tail is deleted, and we don't crash!
     15 ;
     16 ; CHECK-LABEL: @t
     17 ; CHECK-LABEL: for.cond127.preheader:
     18 ; CHECK-NOT: for.cond127:
     19 ; CHECK-LABEL: for.body129:
     20 define void @t() {
     21 entry:
     22   br label %for.body102
     23 
     24 for.body102:
     25   br i1 undef, label %for.cond127.preheader, label %for.inc203
     26 
     27 for.cond127.preheader:
     28   br label %for.body129
     29 
     30 for.cond127:
     31   %cmp128 = icmp slt i32 %inc191, 2
     32   br i1 %cmp128, label %for.body129, label %for.end192
     33 
     34 for.body129:
     35   %uv.013 = phi i32 [ 0, %for.cond127.preheader ], [ %inc191, %for.cond127 ]
     36   %idxprom130 = sext i32 %uv.013 to i64
     37   br i1 undef, label %for.cond135.preheader.lr.ph, label %for.end185
     38 
     39 for.cond135.preheader.lr.ph:
     40   br i1 undef, label %for.cond135.preheader.lr.ph.split.us, label %for.cond135.preheader.lr.ph.split_crit_edge
     41 
     42 for.cond135.preheader.lr.ph.split_crit_edge:
     43   br label %for.cond135.preheader.lr.ph.split
     44 
     45 for.cond135.preheader.lr.ph.split.us:
     46   br label %for.cond135.preheader.us
     47 
     48 for.cond135.preheader.us:
     49   %block_y.09.us = phi i32 [ 0, %for.cond135.preheader.lr.ph.split.us ], [ %add184.us, %for.cond132.us ]
     50   br i1 true, label %for.cond138.preheader.lr.ph.us, label %for.end178.us
     51 
     52 for.end178.us:
     53   %add184.us = add nsw i32 %block_y.09.us, 4
     54   br i1 undef, label %for.end185split.us-lcssa.us, label %for.cond132.us
     55 
     56 for.end174.us:
     57   br i1 undef, label %for.cond138.preheader.us, label %for.cond135.for.end178_crit_edge.us
     58 
     59 for.inc172.us:
     60   br i1 undef, label %for.cond142.preheader.us, label %for.end174.us
     61 
     62 for.body145.us:
     63   %arrayidx163.us = getelementptr inbounds %struct.Params* undef, i64 0, i32 0, i64 %idxprom130, i64 %idxprom146.us
     64   br i1 undef, label %for.body145.us, label %for.inc172.us
     65 
     66 for.cond142.preheader.us:
     67   %j.04.us = phi i32 [ %block_y.09.us, %for.cond138.preheader.us ], [ undef, %for.inc172.us ]
     68   %idxprom146.us = sext i32 %j.04.us to i64
     69   br label %for.body145.us
     70 
     71 for.cond138.preheader.us:
     72   br label %for.cond142.preheader.us
     73 
     74 for.cond132.us:
     75   br i1 undef, label %for.cond135.preheader.us, label %for.cond132.for.end185_crit_edge.us-lcssa.us
     76 
     77 for.cond138.preheader.lr.ph.us:
     78   br label %for.cond138.preheader.us
     79 
     80 for.cond135.for.end178_crit_edge.us:
     81   br label %for.end178.us
     82 
     83 for.end185split.us-lcssa.us:
     84   br label %for.end185split
     85 
     86 for.cond132.for.end185_crit_edge.us-lcssa.us:
     87   br label %for.cond132.for.end185_crit_edge
     88 
     89 for.cond135.preheader.lr.ph.split:
     90   br label %for.end185split
     91 
     92 for.end185split:
     93   br label %for.end185
     94 
     95 for.cond132.for.end185_crit_edge:
     96   br label %for.end185
     97 
     98 for.end185:
     99   %inc191 = add nsw i32 %uv.013, 1
    100   br i1 false, label %for.end192, label %for.cond127
    101 
    102 for.end192:
    103   br label %for.inc203
    104 
    105 for.inc203:
    106   br label %for.end205
    107 
    108 for.end205:
    109   ret void
    110 }
    111