Home | History | Annotate | Download | only in LoopStrengthReduce
      1 ; RUN: opt -loop-reduce -S < %s | FileCheck %s
      2 ;
      3 ; PR11356: likely wrong code bug
      4 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
      5 target triple = "x86_64-apple-darwin"
      6 
      7 @g_66 = global [1 x i32] zeroinitializer, align 4
      8 @g_775 = global i32 0, align 4
      9 @g_752 = global i32 0, align 4
     10 @g_3 = global i32 0, align 4
     11 
     12 ; Ensure that %div.i.i.us is not hoisted.
     13 ; CHECK-LABEL: @main(
     14 ; CHECK: for.body.i.i.us:
     15 ; CHECK: %div.i.i.i.us
     16 ; CHECK: %cmp5.i.i.us
     17 define i32 @main() nounwind uwtable ssp {
     18 entry:
     19   %l_2 = alloca [1 x i32], align 4
     20   %arrayidx = getelementptr inbounds [1 x i32], [1 x i32]* %l_2, i64 0, i64 0
     21   store i32 0, i32* %arrayidx, align 4
     22   %tmp = load i32, i32* @g_3, align 4
     23   %idxprom = sext i32 %tmp to i64
     24   %arrayidx1 = getelementptr inbounds [1 x i32], [1 x i32]* %l_2, i64 0, i64 %idxprom
     25   %tmp1 = load i32, i32* %arrayidx1, align 4
     26   %conv.i.i = and i32 %tmp1, 65535
     27   %tobool.i.i.i = icmp ne i32 %tmp, 0
     28   br label %codeRepl
     29 
     30 codeRepl.loopexit.us-lcssa:                       ; preds = %for.body.i.i, %codeRepl5
     31   br label %codeRepl.loopexit
     32 
     33 codeRepl.loopexit:                                ; preds = %codeRepl.loopexit.us-lcssa.us, %codeRepl.loopexit.us-lcssa
     34   br label %codeRepl
     35 
     36 codeRepl:                                         ; preds = %codeRepl.loopexit, %entry
     37   br i1 %tobool.i.i.i, label %codeRepl.split.us, label %codeRepl.codeRepl.split_crit_edge
     38 
     39 codeRepl.codeRepl.split_crit_edge:                ; preds = %codeRepl
     40   br label %codeRepl.split
     41 
     42 codeRepl.split.us:                                ; preds = %codeRepl
     43   br label %for.cond.i.i.us
     44 
     45 for.cond.i.i.us:                                  ; preds = %for.inc.i.i.us, %codeRepl.split.us
     46   %tmp2 = phi i32 [ 0, %codeRepl.split.us ], [ %add.i.i.us, %for.inc.i.i.us ]
     47   br label %codeRepl5.us
     48 
     49 for.inc.i.i.us:                                   ; preds = %for.body.i.i.us
     50   %add.i.i.us = add nsw i32 %tmp2, 1
     51   store i32 %add.i.i.us, i32* @g_752, align 4
     52   br label %for.cond.i.i.us
     53 
     54 for.body.i.i.us:                                  ; preds = %codeRepl5.us
     55   %div.i.i.i.us = udiv i32 1, %conv.i.i
     56   %cmp5.i.i.us = icmp eq i32 %div.i.i.i.us, %tmp2
     57   br i1 %cmp5.i.i.us, label %codeRepl.loopexit.us-lcssa.us, label %for.inc.i.i.us
     58 
     59 codeRepl5.us:                                     ; preds = %for.cond.i.i.us
     60   br i1 true, label %codeRepl.loopexit.us-lcssa.us, label %for.body.i.i.us
     61 
     62 codeRepl.loopexit.us-lcssa.us:                    ; preds = %codeRepl5.us, %for.body.i.i.us
     63   br label %codeRepl.loopexit
     64 
     65 codeRepl.split:                                   ; preds = %codeRepl.codeRepl.split_crit_edge
     66   br label %for.cond.i.i
     67 
     68 for.cond.i.i:                                     ; preds = %for.inc.i.i, %codeRepl.split
     69   %tmp3 = phi i32 [ 0, %codeRepl.split ], [ %add.i.i, %for.inc.i.i ]
     70   br label %codeRepl5
     71 
     72 codeRepl5:                                        ; preds = %for.cond.i.i
     73   br i1 true, label %codeRepl.loopexit.us-lcssa, label %for.body.i.i
     74 
     75 for.body.i.i:                                     ; preds = %codeRepl5
     76   %cmp5.i.i = icmp eq i32 0, %tmp3
     77   br i1 %cmp5.i.i, label %codeRepl.loopexit.us-lcssa, label %for.inc.i.i
     78 
     79 for.inc.i.i:                                      ; preds = %for.body.i.i
     80   %add.i.i = add nsw i32 %tmp3, 1
     81   store i32 %add.i.i, i32* @g_752, align 4
     82   br label %for.cond.i.i
     83 
     84 func_4.exit:                                      ; No predecessors!
     85   ret i32 0
     86 }
     87