1 ; RUN: opt %loadPolly -polly-codegen -S \
2 ; RUN: -polly-invariant-load-hoisting=true < %s | FileCheck %s
4 ; bugpoint-reduced testcase of MiBench/consumer-lame/quantize-pvt.c from the
6 ; It features a SCEV that is used in two BasicBlock within a non-affine
7 ; subregion where none of the blocks dominate the other. We check that the SCEV
8 ; is expanded independently for both BasicBlocks instead of just once for the
11 ; CHECK-LABEL: polly.stmt.if.then.110:
12 ; CHECK: %[[R1_1:[0-9]*]] = mul nuw nsw i64 %polly.indvar[[R0_1:[0-9]*]], 120
13 ; CHECK: %scevgep[[R1_2:[0-9]*]] = getelementptr i8, ptr %scevgep{{[0-9]*}}, i64 %[[R1_1]]
14 ; CHECK: store i32 0, ptr %scevgep[[R1_2]], align 8
16 ; CHECK-LABEL: polly.stmt.if.else:
17 ; CHECK: %[[R2_1:[0-9]*]] = mul nuw nsw i64 %polly.indvar[[R0_1]], 120
18 ; CHECK: %scevgep[[R2_2:[0-9]*]] = getelementptr i8, ptr %scevgep{{[0-9]*}}, i64 %[[R2_1]]
19 ; CHECK: store i32 21, ptr %scevgep[[R2_2]], align 8
21 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
22 target triple = "x86_64-unknown-linux-gnu"
24 %struct.gr_info.4.59.136.224.290 = type { i32, i32, i32, i32, i32, i32, i32, i32, [3 x i32], [3 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, [4 x i32] }
25 %struct.gr_info_ss.5.60.137.225.291 = type { %struct.gr_info.4.59.136.224.290 }
26 %struct.anon.6.61.138.226.292 = type { [2 x %struct.gr_info_ss.5.60.137.225.291] }
27 %struct.III_side_info_t.7.62.139.227.293 = type { i32, i32, i32, [2 x [4 x i32]], [2 x %struct.anon.6.61.138.226.292] }
28 %struct.lame_global_flags.3.58.135.223.289 = type { i64, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, i32, i32, float, i32, i32, i32, i64, i64, i32, i32, i32, i32, i32, i32, i32, i32, float, i32, i32, i32, float, float, float, float, i32, i32, i32, i32, i32, i32, i32, i32 }
30 @convert_mdct = external global i32, align 4
31 @reduce_sidechannel = external global i32, align 4
33 ; Function Attrs: nounwind uwtable
34 define void @iteration_init(ptr %gfp, ptr %l3_side, ptr %l3_enc) #0 {
36 %resvDrain = getelementptr inbounds %struct.III_side_info_t.7.62.139.227.293, ptr %l3_side, i64 0, i32 2
37 store i32 0, ptr %resvDrain, align 8
38 store i32 0, ptr @convert_mdct, align 4
39 store i32 0, ptr @reduce_sidechannel, align 4
40 %mode_gr = getelementptr inbounds %struct.lame_global_flags.3.58.135.223.289, ptr %gfp, i64 0, i32 45
41 %0 = load i32, ptr %mode_gr, align 8
42 %cmp95.145 = icmp sgt i32 %0, 0
43 br i1 %cmp95.145, label %for.cond.98.preheader, label %for.cond.120.preheader
45 for.cond.98.preheader: ; preds = %for.inc.117, %entry
46 %indvars.iv157 = phi i64 [ %indvars.iv.next158, %for.inc.117 ], [ 0, %entry ]
47 %stereo = getelementptr inbounds %struct.lame_global_flags.3.58.135.223.289, ptr %gfp, i64 0, i32 46
48 %1 = load i32, ptr %stereo, align 4
49 %cmp99.143 = icmp sgt i32 %1, 0
50 br i1 %cmp99.143, label %for.body.101, label %for.inc.117
52 for.cond.120.preheader: ; preds = %for.inc.117, %entry
55 for.body.101: ; preds = %for.inc.114, %for.cond.98.preheader
56 %indvars.iv155 = phi i64 [ %indvars.iv.next156, %for.inc.114 ], [ 0, %for.cond.98.preheader ]
57 %block_type = getelementptr inbounds %struct.III_side_info_t.7.62.139.227.293, ptr %l3_side, i64 0, i32 4, i64 %indvars.iv157, i32 0, i64 %indvars.iv155, i32 0, i32 6
58 %2 = load i32, ptr %block_type, align 8
59 %cmp108 = icmp eq i32 %2, 2
60 %sfb_lmax = getelementptr inbounds %struct.III_side_info_t.7.62.139.227.293, ptr %l3_side, i64 0, i32 4, i64 %indvars.iv157, i32 0, i64 %indvars.iv155, i32 0, i32 16
61 br i1 %cmp108, label %if.then.110, label %if.else
63 if.then.110: ; preds = %for.body.101
64 store i32 0, ptr %sfb_lmax, align 8
65 %sfb_smax = getelementptr inbounds %struct.III_side_info_t.7.62.139.227.293, ptr %l3_side, i64 0, i32 4, i64 %indvars.iv157, i32 0, i64 %indvars.iv155, i32 0, i32 17
66 store i32 0, ptr %sfb_smax, align 4
69 if.else: ; preds = %for.body.101
70 store i32 21, ptr %sfb_lmax, align 8
71 %sfb_smax112 = getelementptr inbounds %struct.III_side_info_t.7.62.139.227.293, ptr %l3_side, i64 0, i32 4, i64 %indvars.iv157, i32 0, i64 %indvars.iv155, i32 0, i32 17
72 store i32 12, ptr %sfb_smax112, align 4
75 for.inc.114: ; preds = %if.else, %if.then.110
76 %indvars.iv.next156 = add nuw nsw i64 %indvars.iv155, 1
77 %3 = load i32, ptr %stereo, align 4
78 %4 = sext i32 %3 to i64
79 %cmp99 = icmp slt i64 %indvars.iv.next156, %4
80 br i1 %cmp99, label %for.body.101, label %for.inc.117
82 for.inc.117: ; preds = %for.inc.114, %for.cond.98.preheader
83 %indvars.iv.next158 = add nuw nsw i64 %indvars.iv157, 1
84 %5 = load i32, ptr %mode_gr, align 8
85 %6 = sext i32 %5 to i64
86 %cmp95 = icmp slt i64 %indvars.iv.next158, %6
87 br i1 %cmp95, label %for.cond.98.preheader, label %for.cond.120.preheader
90 attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }