1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -relocation-model=static -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
4 ; The inner loop should require only one add (and no leas either).
7 @flags = external dso_local global [8192 x i8], align 16 ; <ptr> [#uses=1]
9 define void @foo() nounwind {
11 ; CHECK: # %bb.0: # %entry
12 ; CHECK-NEXT: movl $2, %eax
13 ; CHECK-NEXT: .p2align 4, 0x90
14 ; CHECK-NEXT: .LBB0_1: # %bb7
15 ; CHECK-NEXT: # =>This Loop Header: Depth=1
16 ; CHECK-NEXT: # Child Loop BB0_2 Depth 2
17 ; CHECK-NEXT: movl $2, %ecx
18 ; CHECK-NEXT: .p2align 4, 0x90
19 ; CHECK-NEXT: .LBB0_2: # %bb11
20 ; CHECK-NEXT: # Parent Loop BB0_1 Depth=1
21 ; CHECK-NEXT: # => This Inner Loop Header: Depth=2
22 ; CHECK-NEXT: movb $0, flags(%rcx)
23 ; CHECK-NEXT: addq %rax, %rcx
24 ; CHECK-NEXT: cmpq $8192, %rcx # imm = 0x2000
25 ; CHECK-NEXT: jl .LBB0_2
26 ; CHECK-NEXT: # %bb.3: # %bb16
27 ; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
28 ; CHECK-NEXT: incq %rax
29 ; CHECK-NEXT: cmpq $8192, %rax # imm = 0x2000
30 ; CHECK-NEXT: jl .LBB0_1
31 ; CHECK-NEXT: # %bb.4: # %bb20
39 bb7: ; preds = %bb, %bb17
40 %tmp8 = phi i64 [ %tmp18, %bb17 ], [ 2, %bb ] ; <i64> [#uses=2]
46 bb11: ; preds = %bb10, %bb11
47 %tmp12 = phi i64 [ %tmp14, %bb11 ], [ 2, %bb10 ] ; <i64> [#uses=2]
48 %tmp13 = getelementptr inbounds [8192 x i8], ptr @flags, i64 0, i64 %tmp12 ; <ptr> [#uses=1]
49 store i8 0, ptr %tmp13, align 1
50 %tmp14 = add nsw i64 %tmp12, %tmp8 ; <i64> [#uses=2]
51 %tmp15 = icmp slt i64 %tmp14, 8192 ; <i1> [#uses=1]
52 br i1 %tmp15, label %bb11, label %bb16
57 bb17: ; preds = %bb16, %bb7
58 %tmp18 = add nsw i64 %tmp8, 1 ; <i64> [#uses=2]
59 %tmp19 = icmp slt i64 %tmp18, 8192 ; <i1> [#uses=1]
60 br i1 %tmp19, label %bb7, label %bb20
65 bb21: ; preds = %bb20, %entry