1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-- | FileCheck %s
4 @X = common dso_local global i16 0 ; <ptr> [#uses=1]
6 define dso_local i32 @foo(i32 %N) nounwind {
8 ; CHECK: # %bb.0: # %entry
9 ; CHECK-NEXT: xorl %eax, %eax
10 ; CHECK-NEXT: testl %edi, %edi
11 ; CHECK-NEXT: jle .LBB0_2
12 ; CHECK-NEXT: .p2align 4, 0x90
13 ; CHECK-NEXT: .LBB0_1: # %bb
14 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
15 ; CHECK-NEXT: movw %ax, X(%rip)
16 ; CHECK-NEXT: incl %eax
17 ; CHECK-NEXT: cmpl %eax, %edi
18 ; CHECK-NEXT: jne .LBB0_1
19 ; CHECK-NEXT: .LBB0_2: # %return
22 %0 = icmp sgt i32 %N, 0 ; <i1> [#uses=1]
23 br i1 %0, label %bb, label %return
25 bb: ; preds = %bb, %entry
26 %i.03 = phi i32 [ 0, %entry ], [ %indvar.next, %bb ] ; <i32> [#uses=2]
27 %1 = trunc i32 %i.03 to i16 ; <i16> [#uses=1]
28 store volatile i16 %1, ptr @X, align 2
29 %indvar.next = add i32 %i.03, 1 ; <i32> [#uses=2]
30 %exitcond = icmp eq i32 %indvar.next, %N ; <i1> [#uses=1]
31 br i1 %exitcond, label %return, label %bb
33 return: ; preds = %bb, %entry
34 %h = phi i32 [ 0, %entry ], [ %indvar.next, %bb ]