• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt %s -loop-vectorize -force-vector-interleave=2 -force-vector-width=4 -S | FileCheck %s
2
3; Fixes PR43828
4
5define void @test(i32* %B) {
6; CHECK-LABEL: @test(
7; CHECK:       vector.body:
8; CHECK-COUNT-2: sub <4 x i32>
9entry:
10  br label %outer_loop
11
12outer_loop:
13  %local_4 = phi i32 [ 2, %entry ], [ %4, %outer_tail]
14  br label %inner_loop
15
16inner_loop:
17  %local_2 = phi i32 [ 0, %outer_loop ], [ %1, %inner_loop ]
18  %local_3 = phi i32 [ -104, %outer_loop ], [ %0, %inner_loop ]
19  %0 = sub nuw nsw i32 %local_3, %local_4
20  %1 = add nuw nsw i32 %local_2, 1
21  %2 = icmp ugt i32 %local_2, 126
22  br i1 %2, label %outer_tail, label %inner_loop
23
24outer_tail:
25  %3 = phi i32 [ %0, %inner_loop ]
26  store atomic i32 %3, i32 * %B unordered, align 8
27  %4 = add i32 %local_4, 1
28  %5 = icmp slt i32 %4, 6
29  br i1 %5, label %outer_loop, label %exit
30
31exit:
32  ret void
33}
34
35define i32 @multi-instr(i32* noalias nocapture %A, i32* noalias nocapture %B, i32 %inc) {
36; CHECK-LABEL: @multi-instr(
37; CHECK:       vector.body:
38; CHECK-COUNT-4: add <4 x i32>
39entry:
40  br label %loop
41
42loop:
43  %iv = phi i32 [0, %entry], [%iv_inc, %loop]
44  %redu = phi i32 [0, %entry], [%3, %loop]
45  %gepa = getelementptr inbounds i32, i32* %A, i32 %iv
46  %gepb = getelementptr inbounds i32, i32* %B, i32 %iv
47  %0 = load i32, i32* %gepa
48  %1 = load i32, i32* %gepb
49  %2 = add nuw nsw i32 %redu, %0
50  %3 = add nuw nsw i32 %2, %1
51  %iv_inc = add nuw nsw i32 %iv, 1
52  %4 = icmp ult i32 %iv_inc, 128
53  br i1 %4, label %loop, label %exit
54
55exit:
56  %lcssa = phi i32 [%3, %loop]
57  ret i32 %lcssa
58}
59