From a57cc8bc817f3ff7a48bfd8221562e3cc2a2bc10 Mon Sep 17 00:00:00 2001 From: Brendon Cahoon Date: Mon, 20 Apr 2015 16:03:28 +0000 Subject: Recognize n/1 in the SCEV divide function n/1 generates a quotient equal to n and a remainder of 0. If this case is not recognized, then the SCEV divide() function can return a remainder that is greater than or equal to the denominator, which means the delinearized subscripts for the test case will be incorrect. Differential Revision: http://reviews.llvm.org/D9003 llvm-svn: 235311 --- llvm/lib/Analysis/ScalarEvolution.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'llvm/lib/Analysis') diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 37377f0b859..d88b0268651 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -726,6 +726,13 @@ public: return; } + // A simple case when N/1. The quotient is N. + if (Denominator->isOne()) { + *Quotient = Numerator; + *Remainder = D.Zero; + return; + } + // Split the Denominator when it is a product. if (const SCEVMulExpr *T = dyn_cast(Denominator)) { const SCEV *Q, *R; -- cgit v1.2.3