1 ; RUN: opt < %s -loop-reduce -S | FileCheck %s
3 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
4 target triple = "thumbv7m-arm-none-eabi"
6 ; Check that the IV updates (incdec.ptr{,1,2}) are kept in the latch block
7 ; and not moved to the header/exiting block. Inserting them in the header
8 ; doubles register pressure and adds moves.
12 ; CHECK: icmp sgt i32 %n.addr.0, 0
15 ; CHECK: incdec.ptr1 =
16 ; CHECK: incdec.ptr2 =
18 define void @f(float* nocapture readonly %a, float* nocapture readonly %b, float* nocapture %c, i32 %n) {
22 while.cond: ; preds = %while.body, %entry
23 %a.addr.0 = phi float* [ %a, %entry ], [ %incdec.ptr, %while.body ]
24 %b.addr.0 = phi float* [ %b, %entry ], [ %incdec.ptr1, %while.body ]
25 %c.addr.0 = phi float* [ %c, %entry ], [ %incdec.ptr2, %while.body ]
26 %n.addr.0 = phi i32 [ %n, %entry ], [ %dec, %while.body ]
27 %cmp = icmp sgt i32 %n.addr.0, 0
28 br i1 %cmp, label %while.body, label %while.end
30 while.body: ; preds = %while.cond
31 %incdec.ptr = getelementptr inbounds float, float* %a.addr.0, i32 1
32 %tmp = load float, float* %a.addr.0, align 4
33 %incdec.ptr1 = getelementptr inbounds float, float* %b.addr.0, i32 1
34 %tmp1 = load float, float* %b.addr.0, align 4
35 %add = fadd float %tmp, %tmp1
36 %incdec.ptr2 = getelementptr inbounds float, float* %c.addr.0, i32 1
37 store float %add, float* %c.addr.0, align 4
38 %dec = add nsw i32 %n.addr.0, -1
41 while.end: ; preds = %while.cond