diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -10627,6 +10627,9 @@ Changed |= formLCSSARecursively(*L, *DT, LI, SE); Changed |= CFGChanged |= processLoop(L); + + if (Changed) + LAIs->clear(); } // Process each loop nest in the function. diff --git a/llvm/test/Transforms/LoopVectorize/X86/pr59319.ll b/llvm/test/Transforms/LoopVectorize/X86/pr59319.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Transforms/LoopVectorize/X86/pr59319.ll @@ -0,0 +1,50 @@ +; RUN: opt -passes=loop-distribute,loop-vectorize -enable-loop-distribute -S \ +; RUN: %s | FileCheck %s +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" +; REQUIRES: x86-registered-target + +define void @reduced(i32* %0, i32* %1, i64 %iv, i32* %2, i64 %iv76, i64 %iv93) { +; CHECK-LABEL: @reduced( +entry: + br label %loop.1 + +loop.1: ; preds = %loop.1, %entry + %iv761 = phi i64 [ 0, %entry ], [ %iv.next77, %loop.1 ] + %iv4 = phi i64 [ 0, %entry ], [ %iv.next, %loop.1 ] + %iv.next77 = add i64 %iv761, 1 + %arrayidx.i.i50 = getelementptr i32, i32* %0, i64 %iv76 + %iv.next = add i64 %iv4, 1 + %exitcond.not = icmp eq i64 %iv4, %iv + br i1 %exitcond.not, label %loop.2.preheader, label %loop.1 + +loop.2.preheader: ; preds = %loop.1 + br label %loop.2 + +loop.3.lr.ph: ; preds = %loop.2 + %idxprom.i.i61 = and i64 %iv761, 1 + %arrayidx.i.i62 = getelementptr i32, i32* %0, i64 %idxprom.i.i61 + br label %loop.3 + +loop.2: ; preds = %loop.2, %loop.2.preheader + %iv846 = phi i64 [ %iv.next85, %loop.2 ], [ 0, %loop.2.preheader ] + %iv.next87 = add i64 0, 0 + %arrayidx.i.i56 = getelementptr i32, i32* %0, i64 %iv761 + %3 = load i32, i32* %arrayidx.i.i56, align 4 + store i32 0, i32* %1, align 4 + %iv.next85 = add i64 %iv846, 1 + %exitcond92.not = icmp eq i64 %iv846, %iv + br i1 %exitcond92.not, label %loop.3.lr.ph, label %loop.2 + +loop.3: ; preds = %loop.3, %loop.3.lr.ph + %iv932 = phi i64 [ 0, %loop.3.lr.ph ], [ %iv.next94, %loop.3 ] + %4 = load i32, i32* %arrayidx.i.i62, align 4 + %arrayidx.i.i653 = getelementptr i32, i32* %2, i64 %iv93 + store i32 0, i32* %1, align 4 + %iv.next94 = add i64 %iv932, 1 + %exitcond97.not = icmp eq i64 %iv932, %iv + br i1 %exitcond97.not, label %loop.cleanup, label %loop.3 + +loop.cleanup: ; preds = %loop.3 + ret void +}