1; RUN: opt -analyze -enable-new-pm=0 -scalar-evolution < %s | FileCheck %s
2; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s
3
4target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:1"
5
6; Check that we don't have unreasonably huge SCEVs and in particular only a
7; reasonable amount of AddRecs in the notation of %tmp19. If we "simplify" SCEVs
8; too aggressively, we may end up with huge nested expressions.
9define void @test(i32 %x, i64 %y, i1 %cond) {
10
11; CHECK: %tmp19 = mul i32 %tmp17, %tmp18
12; CHECK: ((((((
13; CHECK-NOT: (((((
14; CHECK: %tmp20 = add i32 %tmp19, %x
15
16bb:
17  br label %bb1
18
19bb1:                                              ; preds = %bb3, %bb
20  %tmp = phi i64 [ %y, %bb ], [ %tmp22, %bb3 ]
21  %tmp2 = phi i32 [ %x, %bb ], [ %tmp4, %bb3 ]
22  br label %bb5
23
24bb3:                                              ; preds = %bb5
25  %tmp4 = add i32 %tmp2, %x
26  br label %bb1
27
28bb5:                                              ; preds = %bb5, %bb1
29  %tmp6 = phi i32 [ %tmp23, %bb5 ], [ %tmp2, %bb1 ]
30  %tmp7 = sub i32 -119, %tmp6
31  %tmp8 = mul i32 %tmp7, %x
32  %tmp9 = sub i32 -120, %tmp6
33  %tmp10 = mul i32 %tmp8, %tmp9
34  %tmp11 = mul i32 %x, %tmp10
35  %tmp12 = sub i32 -121, %tmp6
36  %tmp13 = mul i32 %tmp10, %tmp12
37  %tmp14 = mul i32 %tmp11, %tmp13
38  %tmp15 = sub i32 -122, %tmp6
39  %tmp16 = mul i32 %tmp13, %tmp15
40  %tmp17 = mul i32 %tmp14, %tmp16
41  %tmp18 = mul i32 %tmp16, %x
42  %tmp19 = mul i32 %tmp17, %tmp18
43  %tmp20 = add i32 %tmp19, %x
44  %tmp21 = sext i32 %tmp20 to i64
45  %tmp22 = add i64 %y, %tmp21
46  %tmp23 = add i32 %tmp6, 7
47  br i1 %cond, label %bb5, label %bb3
48}
49