Skip to content

Commit 64edecc

Browse files
author
git apple-llvm automerger
committed
Merge commit '6481a7649500' from llvm.org/master into apple/main
2 parents faed8f9 + 6481a76 commit 64edecc

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
; RUN: opt -O2 -S %s | FileCheck %s
2+
; RUN: opt -passes='default<O2>' -S %s | FileCheck %s
3+
4+
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
5+
target triple = "x86_64-apple-macosx"
6+
7+
; The loop below needs to be peeled first to eliminate the constant PHI %first
8+
; before loop vectorization.
9+
;
10+
; Test case from PR47671.
11+
12+
define i32 @test(i32* readonly %p, i32* readnone %q) {
13+
; CHECK-LABEL: define i32 @test(
14+
; CHECK-NOT: vector.body
15+
;
16+
entry:
17+
%cmp.not7 = icmp eq i32* %p, %q
18+
br i1 %cmp.not7, label %exit, label %loop.ph
19+
20+
loop.ph:
21+
br label %loop
22+
23+
loop:
24+
%sum = phi i32 [ %sum.next, %loop ], [ 0, %loop.ph ]
25+
%first = phi i1 [ false, %loop ], [ true, %loop.ph ]
26+
%iv = phi i32* [ %iv.next, %loop ], [ %p, %loop.ph ]
27+
%add = add nsw i32 %sum, 2
28+
%spec.select = select i1 %first, i32 %sum, i32 %add
29+
%lv = load i32, i32* %iv, align 4
30+
%sum.next = add nsw i32 %lv, %spec.select
31+
%iv.next = getelementptr inbounds i32, i32* %iv, i64 1
32+
%cmp.not = icmp eq i32* %iv.next, %q
33+
br i1 %cmp.not, label %loopexit, label %loop
34+
35+
loopexit:
36+
%sum.next.lcssa = phi i32 [ %sum.next, %loop ]
37+
br label %exit
38+
39+
exit:
40+
%sum.0.lcssa = phi i32 [ 0, %entry ], [ %sum.next.lcssa, %loopexit ]
41+
ret i32 %sum.0.lcssa
42+
}

0 commit comments

Comments
 (0)