xref: /llvm-project/llvm/test/Transforms/LoopVectorize/ARM/tail-folding-reductions-allowed.ll (revision 7d7577256b76e4293f455b8093504d5f7044ab4b)
1; RUN: opt -mtriple=thumbv8.1m.main-arm-eabihf -mattr=+mve.fp -passes=loop-vectorize -tail-predication=enabled -S < %s | \
2; RUN:  FileCheck %s -check-prefixes=COMMON,CHECK
3
4; RUN: opt -mtriple=thumbv8.1m.main-arm-eabihf -mattr=+mve.fp -passes=loop-vectorize -tail-predication=enabled-no-reductions -S < %s | \
5; RUN:  FileCheck %s -check-prefixes=COMMON,NORED
6
7; RUN: opt -mtriple=thumbv8.1m.main-arm-eabihf -mattr=+mve.fp -passes=loop-vectorize -tail-predication=force-enabled-no-reductions -S < %s | \
8; RUN:  FileCheck %s -check-prefixes=COMMON,NORED
9
10target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
11
12; Check that this reduction is allowed, except when reductions are disable on
13; the command line.
14;
15define dso_local i32 @i32_add_reduction(ptr noalias nocapture readonly %B, i32 %N) local_unnamed_addr #0 {
16; COMMON-LABEL: i32_add_reduction(
17; COMMON:       entry:
18; CHECK:        @llvm.get.active.lane.mask
19; NORED-NOT:    @llvm.get.active.lane.mask
20; COMMON:       }
21entry:
22  %cmp6 = icmp sgt i32 %N, 0
23  br i1 %cmp6, label %for.body.preheader, label %for.cond.cleanup
24
25for.body.preheader:
26  br label %for.body
27
28for.cond.cleanup.loopexit:
29  %add.lcssa = phi i32 [ %add, %for.body ]
30  br label %for.cond.cleanup
31
32for.cond.cleanup:
33  %S.0.lcssa = phi i32 [ 1, %entry ], [ %add.lcssa, %for.cond.cleanup.loopexit ]
34  ret i32 %S.0.lcssa
35
36for.body:
37  %i.08 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
38  %S.07 = phi i32 [ %add, %for.body ], [ 1, %for.body.preheader ]
39  %arrayidx = getelementptr inbounds i32, ptr %B, i32 %i.08
40  %0 = load i32, ptr %arrayidx, align 4
41  %add = add nsw i32 %0, %S.07
42  %inc = add nuw nsw i32 %i.08, 1
43  %exitcond = icmp eq i32 %inc, %N
44  br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body
45}
46