1 ; RUN: llvm-as < %s | opt -indvars -instcombine | llvm-dis | grep 'store int 0'
2 ; Test that -indvars can reduce variable stride IVs. If it can reduce variable
3 ; stride iv's, it will make %iv. and %m.0.0 isomorphic to each other without
4 ; cycles, allowing the tmp.21 subtraction to be eliminated.
6 void %vnum_test8(int* %data) {
8 %tmp.1 = getelementptr int* %data, int 3 ; <int*> [#uses=1]
9 %tmp.2 = load int* %tmp.1 ; <int> [#uses=2]
10 %tmp.4 = getelementptr int* %data, int 4 ; <int*> [#uses=1]
11 %tmp.5 = load int* %tmp.4 ; <int> [#uses=2]
12 %tmp.8 = getelementptr int* %data, int 2 ; <int*> [#uses=1]
13 %tmp.9 = load int* %tmp.8 ; <int> [#uses=3]
14 %tmp.125 = setgt int %tmp.2, 0 ; <bool> [#uses=1]
15 br bool %tmp.125, label %no_exit.preheader, label %return
17 no_exit.preheader: ; preds = %entry
18 %tmp.16 = getelementptr int* %data, int %tmp.9 ; <int*> [#uses=1]
21 no_exit: ; preds = %no_exit, %no_exit.preheader
22 %iv. = phi uint [ 0, %no_exit.preheader ], [ %iv..inc, %no_exit ] ; <uint> [#uses=1]
23 %iv. = phi int [ %tmp.5, %no_exit.preheader ], [ %iv..inc, %no_exit ] ; <int> [#uses=2]
24 %m.0.0 = phi int [ %tmp.5, %no_exit.preheader ], [ %tmp.24, %no_exit ] ; <int> [#uses=2]
25 store int 2, int* %tmp.16
26 %tmp.21 = sub int %m.0.0, %iv. ; <int> [#uses=1]
27 store int %tmp.21, int* %data
28 %tmp.24 = add int %m.0.0, %tmp.9 ; <int> [#uses=1]
29 %iv..inc = add int %tmp.9, %iv. ; <int> [#uses=1]
30 %iv..inc = add uint %iv., 1 ; <uint> [#uses=2]
31 %iv..inc1 = cast uint %iv..inc to int ; <int> [#uses=1]
32 %tmp.12 = setlt int %iv..inc1, %tmp.2 ; <bool> [#uses=1]
33 br bool %tmp.12, label %no_exit, label %return.loopexit
35 return.loopexit: ; preds = %no_exit
38 return: ; preds = %return.loopexit, %entry