1 ; RUN: opt < %s -passes=indvars -S | FileCheck %s
3 ; Indvars should be able to eliminate all of the sign extensions
6 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-n32:64"
7 @pow_2_tab = external constant [0 x float] ; <ptr> [#uses=1]
8 @pow_2_025_tab = external constant [0 x float] ; <ptr> [#uses=1]
9 @i_pow_2_tab = external constant [0 x float] ; <ptr> [#uses=1]
10 @i_pow_2_025_tab = external constant [0 x float] ; <ptr> [#uses=1]
12 define void @foo(i32 %gain, i32 %noOfLines, ptr %quaSpectrum, ptr %iquaSpectrum, ptr %pow4_3_tab_ptr) nounwind {
17 %t0 = icmp slt i32 %gain, 0 ; <i1> [#uses=1]
18 br i1 %t0, label %bb1, label %bb2
21 %t1 = sub i32 0, %gain ; <i32> [#uses=1]
22 %t2 = sub i32 0, %gain ; <i32> [#uses=1]
25 bb2: ; preds = %bb1, %entry
26 %pow_2_tab.pn = phi ptr [ @i_pow_2_tab, %bb1 ], [ @pow_2_tab, %entry ] ; <ptr> [#uses=1]
27 %.pn3.in.in = phi i32 [ %t1, %bb1 ], [ %gain, %entry ] ; <i32> [#uses=1]
28 %pow_2_025_tab.pn = phi ptr [ @i_pow_2_025_tab, %bb1 ], [ @pow_2_025_tab, %entry ] ; <ptr> [#uses=1]
29 %.pn2.in.in = phi i32 [ %t2, %bb1 ], [ %gain, %entry ] ; <i32> [#uses=1]
30 %.pn3.in = ashr i32 %.pn3.in.in, 2 ; <i32> [#uses=1]
31 %.pn2.in = and i32 %.pn2.in.in, 3 ; <i32> [#uses=1]
32 %.pn3 = sext i32 %.pn3.in to i64 ; <i64> [#uses=1]
33 %.pn2 = zext i32 %.pn2.in to i64 ; <i64> [#uses=1]
34 %.pn.in = getelementptr [0 x float], ptr %pow_2_tab.pn, i64 0, i64 %.pn3 ; <ptr> [#uses=1]
35 %.pn1.in = getelementptr [0 x float], ptr %pow_2_025_tab.pn, i64 0, i64 %.pn2 ; <ptr> [#uses=1]
36 %.pn = load float, ptr %.pn.in ; <float> [#uses=1]
37 %.pn1 = load float, ptr %.pn1.in ; <float> [#uses=1]
38 %invQuantizer.0 = fmul float %.pn, %.pn1 ; <float> [#uses=4]
39 %t3 = ashr i32 %noOfLines, 2 ; <i32> [#uses=1]
40 %t4 = icmp sgt i32 %t3, 0 ; <i1> [#uses=1]
41 br i1 %t4, label %bb.nph, label %return
43 bb.nph: ; preds = %bb2
44 %t5 = ashr i32 %noOfLines, 2 ; <i32> [#uses=1]
47 bb3: ; preds = %bb4, %bb.nph
48 %i.05 = phi i32 [ %t49, %bb4 ], [ 0, %bb.nph ] ; <i32> [#uses=9]
49 %k.04 = phi i32 [ %t48, %bb4 ], [ 0, %bb.nph ] ; <i32> [#uses=1]
50 %t6 = sext i32 %i.05 to i64 ; <i64> [#uses=1]
51 %t7 = getelementptr i32, ptr %quaSpectrum, i64 %t6 ; <ptr> [#uses=1]
52 %t8 = load i32, ptr %t7, align 4 ; <i32> [#uses=1]
53 %t9 = zext i32 %t8 to i64 ; <i64> [#uses=1]
54 %t10 = getelementptr float, ptr %pow4_3_tab_ptr, i64 %t9 ; <ptr> [#uses=1]
55 %t11 = load float, ptr %t10, align 4 ; <float> [#uses=1]
56 %t12 = or disjoint i32 %i.05, 1 ; <i32> [#uses=1]
57 %t13 = sext i32 %t12 to i64 ; <i64> [#uses=1]
58 %t14 = getelementptr i32, ptr %quaSpectrum, i64 %t13 ; <ptr> [#uses=1]
59 %t15 = load i32, ptr %t14, align 4 ; <i32> [#uses=1]
60 %t16 = zext i32 %t15 to i64 ; <i64> [#uses=1]
61 %t17 = getelementptr float, ptr %pow4_3_tab_ptr, i64 %t16 ; <ptr> [#uses=1]
62 %t18 = load float, ptr %t17, align 4 ; <float> [#uses=1]
63 %t19 = or disjoint i32 %i.05, 2 ; <i32> [#uses=1]
64 %t20 = sext i32 %t19 to i64 ; <i64> [#uses=1]
65 %t21 = getelementptr i32, ptr %quaSpectrum, i64 %t20 ; <ptr> [#uses=1]
66 %t22 = load i32, ptr %t21, align 4 ; <i32> [#uses=1]
67 %t23 = zext i32 %t22 to i64 ; <i64> [#uses=1]
68 %t24 = getelementptr float, ptr %pow4_3_tab_ptr, i64 %t23 ; <ptr> [#uses=1]
69 %t25 = load float, ptr %t24, align 4 ; <float> [#uses=1]
70 %t26 = or disjoint i32 %i.05, 3 ; <i32> [#uses=1]
71 %t27 = sext i32 %t26 to i64 ; <i64> [#uses=1]
72 %t28 = getelementptr i32, ptr %quaSpectrum, i64 %t27 ; <ptr> [#uses=1]
73 %t29 = load i32, ptr %t28, align 4 ; <i32> [#uses=1]
74 %t30 = zext i32 %t29 to i64 ; <i64> [#uses=1]
75 %t31 = getelementptr float, ptr %pow4_3_tab_ptr, i64 %t30 ; <ptr> [#uses=1]
76 %t32 = load float, ptr %t31, align 4 ; <float> [#uses=1]
77 %t33 = fmul float %t11, %invQuantizer.0 ; <float> [#uses=1]
78 %t34 = sext i32 %i.05 to i64 ; <i64> [#uses=1]
79 %t35 = getelementptr float, ptr %iquaSpectrum, i64 %t34 ; <ptr> [#uses=1]
80 store float %t33, ptr %t35, align 4
81 %t36 = or disjoint i32 %i.05, 1 ; <i32> [#uses=1]
82 %t37 = fmul float %t18, %invQuantizer.0 ; <float> [#uses=1]
83 %t38 = sext i32 %t36 to i64 ; <i64> [#uses=1]
84 %t39 = getelementptr float, ptr %iquaSpectrum, i64 %t38 ; <ptr> [#uses=1]
85 store float %t37, ptr %t39, align 4
86 %t40 = or disjoint i32 %i.05, 2 ; <i32> [#uses=1]
87 %t41 = fmul float %t25, %invQuantizer.0 ; <float> [#uses=1]
88 %t42 = sext i32 %t40 to i64 ; <i64> [#uses=1]
89 %t43 = getelementptr float, ptr %iquaSpectrum, i64 %t42 ; <ptr> [#uses=1]
90 store float %t41, ptr %t43, align 4
91 %t44 = or disjoint i32 %i.05, 3 ; <i32> [#uses=1]
92 %t45 = fmul float %t32, %invQuantizer.0 ; <float> [#uses=1]
93 %t46 = sext i32 %t44 to i64 ; <i64> [#uses=1]
94 %t47 = getelementptr float, ptr %iquaSpectrum, i64 %t46 ; <ptr> [#uses=1]
95 store float %t45, ptr %t47, align 4
96 %t48 = add i32 %k.04, 1 ; <i32> [#uses=2]
97 %t49 = add i32 %i.05, 4 ; <i32> [#uses=1]
101 %t50 = icmp sgt i32 %t5, %t48 ; <i1> [#uses=1]
102 br i1 %t50, label %bb3, label %bb4.return_crit_edge
104 bb4.return_crit_edge: ; preds = %bb4
107 return: ; preds = %bb4.return_crit_edge, %bb2