From 6481a764950055a08a5b8e0ba728e7f7299f932c Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Tue, 29 Sep 2020 09:46:57 +0100 Subject: [PATCH] [PhaseOrdering] Add test that requires peeling before vectorization. Test case for PR47671. --- .../X86/peel-before-lv-to-enable-vectorization.ll | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 llvm/test/Transforms/PhaseOrdering/X86/peel-before-lv-to-enable-vectorization.ll diff --git a/llvm/test/Transforms/PhaseOrdering/X86/peel-before-lv-to-enable-vectorization.ll b/llvm/test/Transforms/PhaseOrdering/X86/peel-before-lv-to-enable-vectorization.ll new file mode 100644 index 0000000..a87a023 --- /dev/null +++ b/llvm/test/Transforms/PhaseOrdering/X86/peel-before-lv-to-enable-vectorization.ll @@ -0,0 +1,42 @@ +; RUN: opt -O2 -S %s | FileCheck %s +; RUN: opt -passes='default' -S %s | FileCheck %s + +target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx" + +; The loop below needs to be peeled first to eliminate the constant PHI %first +; before loop vectorization. +; +; Test case from PR47671. + +define i32 @test(i32* readonly %p, i32* readnone %q) { +; CHECK-LABEL: define i32 @test( +; CHECK-NOT: vector.body +; +entry: + %cmp.not7 = icmp eq i32* %p, %q + br i1 %cmp.not7, label %exit, label %loop.ph + +loop.ph: + br label %loop + +loop: + %sum = phi i32 [ %sum.next, %loop ], [ 0, %loop.ph ] + %first = phi i1 [ false, %loop ], [ true, %loop.ph ] + %iv = phi i32* [ %iv.next, %loop ], [ %p, %loop.ph ] + %add = add nsw i32 %sum, 2 + %spec.select = select i1 %first, i32 %sum, i32 %add + %lv = load i32, i32* %iv, align 4 + %sum.next = add nsw i32 %lv, %spec.select + %iv.next = getelementptr inbounds i32, i32* %iv, i64 1 + %cmp.not = icmp eq i32* %iv.next, %q + br i1 %cmp.not, label %loopexit, label %loop + +loopexit: + %sum.next.lcssa = phi i32 [ %sum.next, %loop ] + br label %exit + +exit: + %sum.0.lcssa = phi i32 [ 0, %entry ], [ %sum.next.lcssa, %loopexit ] + ret i32 %sum.0.lcssa +} -- 2.7.4