xref: /llvm-project/llvm/test/CodeGen/X86/loop-strength-reduce5.ll (revision e6bf48d11047e970cb24554a01b65b566d6b5d22)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i686-- | FileCheck %s
3
4@X = weak global i16 0		; <ptr> [#uses=1]
5@Y = weak global i16 0		; <ptr> [#uses=1]
6
7define void @foo(i32 %N) nounwind {
8; CHECK-LABEL: foo:
9; CHECK:       # %bb.0: # %entry
10; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %eax
11; CHECK-NEXT:    testl %eax, %eax
12; CHECK-NEXT:    jle .LBB0_3
13; CHECK-NEXT:  # %bb.1: # %bb.preheader
14; CHECK-NEXT:    xorl %ecx, %ecx
15; CHECK-NEXT:    xorl %edx, %edx
16; CHECK-NEXT:    .p2align 4
17; CHECK-NEXT:  .LBB0_2: # %bb
18; CHECK-NEXT:    # =>This Inner Loop Header: Depth=1
19; CHECK-NEXT:    movw %dx, X
20; CHECK-NEXT:    movw %cx, Y
21; CHECK-NEXT:    incl %edx
22; CHECK-NEXT:    addl $4, %ecx
23; CHECK-NEXT:    cmpl %edx, %eax
24; CHECK-NEXT:    jne .LBB0_2
25; CHECK-NEXT:  .LBB0_3: # %return
26; CHECK-NEXT:    retl
27entry:
28	%tmp1019 = icmp sgt i32 %N, 0		; <i1> [#uses=1]
29	br i1 %tmp1019, label %bb, label %return
30
31bb:		; preds = %bb, %entry
32	%i.014.0 = phi i32 [ 0, %entry ], [ %indvar.next, %bb ]		; <i32> [#uses=2]
33	%tmp1 = trunc i32 %i.014.0 to i16		; <i16> [#uses=2]
34	store volatile i16 %tmp1, ptr @X, align 2
35	%tmp34 = shl i16 %tmp1, 2		; <i16> [#uses=1]
36	store volatile i16 %tmp34, ptr @Y, align 2
37	%indvar.next = add i32 %i.014.0, 1		; <i32> [#uses=2]
38	%exitcond = icmp eq i32 %indvar.next, %N		; <i1> [#uses=1]
39	br i1 %exitcond, label %return, label %bb
40
41return:		; preds = %bb, %entry
42	ret void
43}
44