From 02f0b379f56319eb49424bdfb96d567454cc77c5 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Tue, 11 Jun 2019 23:21:24 +0000 Subject: [PATCH] Fix a bug in getSCEVAtScope w.r.t. non-canonical loops The issue is that if we have a loop with multiple predecessors outside the loop, the code was expecting to merge them and only return if equal, but instead returned the first one seen. I have no idea if this actually tripped anywhere. I noticed it by accident when reading the code and have no idea how to go about constructing a test case. llvm-svn: 363112 --- llvm/lib/Analysis/ScalarEvolution.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index a7b7fa262383..dc2d32856cc4 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -8126,9 +8126,9 @@ const SCEV *ScalarEvolution::computeSCEVAtScope(const SCEV *V, const Loop *L) { break; } } - if (!MultipleInitValues && InitValue) - return getSCEV(InitValue); } + if (!MultipleInitValues && InitValue) + return getSCEV(InitValue); } // Okay, we know how many times the containing loop executes. If // this is a constant evolving PHI node, get the final value at