From b840a6d6f40bc487865f32a87a7e092326029e2c Mon Sep 17 00:00:00 2001 From: Matthew Simpson Date: Thu, 3 Mar 2016 16:12:01 +0000 Subject: [LoopUtils, LV] Fix PR26734 The vectorization of first-order recurrences (r261346) caused PR26734. When detecting these recurrences, we need to ensure that the previous value is actually defined inside the loop. This patch includes the fix and test case. llvm-svn: 262624 --- llvm/lib/Transforms/Utils/LoopUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/lib/Transforms/Utils/LoopUtils.cpp') diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp index 42ba0124db1..1f84eca6059 100644 --- a/llvm/lib/Transforms/Utils/LoopUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp @@ -543,7 +543,7 @@ bool RecurrenceDescriptor::isFirstOrderRecurrence(PHINode *Phi, Loop *TheLoop, // Get the previous value. The previous value comes from the latch edge while // the initial value comes form the preheader edge. auto *Previous = dyn_cast(Phi->getIncomingValueForBlock(Latch)); - if (!Previous) + if (!Previous || !TheLoop->contains(Previous)) return false; // Ensure every user of the phi node is dominated by the previous value. The -- cgit v1.2.3