Home | History | Annotate | Download | only in IndVarSimplify
      1 ; RUN: opt < %s -indvars -instcombine -S | FileCheck %s
      2 ;
      3 ; Test that -indvars can reduce variable stride IVs.  If it can reduce variable
      4 ; stride iv's, it will make %iv. and %m.0.0 isomorphic to each other without
      5 ; cycles, allowing the tmp.21 subtraction to be eliminated.
      6 
      7 define void @vnum_test8(i32* %data) {
      8 entry:
      9         %tmp.1 = getelementptr i32, i32* %data, i32 3                ; <i32*> [#uses=1]
     10         %tmp.2 = load i32, i32* %tmp.1               ; <i32> [#uses=2]
     11         %tmp.4 = getelementptr i32, i32* %data, i32 4                ; <i32*> [#uses=1]
     12         %tmp.5 = load i32, i32* %tmp.4               ; <i32> [#uses=2]
     13         %tmp.8 = getelementptr i32, i32* %data, i32 2                ; <i32*> [#uses=1]
     14         %tmp.9 = load i32, i32* %tmp.8               ; <i32> [#uses=3]
     15         %tmp.125 = icmp sgt i32 %tmp.2, 0               ; <i1> [#uses=1]
     16         br i1 %tmp.125, label %no_exit.preheader, label %return
     17 
     18 no_exit.preheader:              ; preds = %entry
     19         %tmp.16 = getelementptr i32, i32* %data, i32 %tmp.9          ; <i32*> [#uses=1]
     20         br label %no_exit
     21 
     22 ; CHECK: store i32 0
     23 no_exit:                ; preds = %no_exit, %no_exit.preheader
     24         %iv.ui = phi i32 [ 0, %no_exit.preheader ], [ %iv..inc.ui, %no_exit ]           ; <i32> [#uses=1]
     25         %iv. = phi i32 [ %tmp.5, %no_exit.preheader ], [ %iv..inc, %no_exit ]           ; <i32> [#uses=2]
     26         %m.0.0 = phi i32 [ %tmp.5, %no_exit.preheader ], [ %tmp.24, %no_exit ]          ; <i32> [#uses=2]
     27         store i32 2, i32* %tmp.16
     28         %tmp.21 = sub i32 %m.0.0, %iv.          ; <i32> [#uses=1]
     29         store i32 %tmp.21, i32* %data
     30         %tmp.24 = add i32 %m.0.0, %tmp.9                ; <i32> [#uses=1]
     31         %iv..inc = add i32 %tmp.9, %iv.         ; <i32> [#uses=1]
     32         %iv..inc.ui = add i32 %iv.ui, 1         ; <i32> [#uses=2]
     33         %iv..inc1 = bitcast i32 %iv..inc.ui to i32              ; <i32> [#uses=1]
     34         %tmp.12 = icmp slt i32 %iv..inc1, %tmp.2                ; <i1> [#uses=1]
     35         br i1 %tmp.12, label %no_exit, label %return.loopexit
     36 
     37 return.loopexit:                ; preds = %no_exit
     38         br label %return
     39 
     40 return:         ; preds = %return.loopexit, %entry
     41         ret void
     42 }
     43 
     44