[PATCH] [SCEV][LoopVectorize] Allow ScalarEvolution to make assumptions about overflows

Sanjoy Das sanjoy at playingwithpointers.com
Sun Jun 14 15:20:45 PDT 2015


> On Jun 11, 2015, at 2:57 AM, Silviu Baranga <Silviu.Baranga at arm.com> wrote:
> 
> Ping? (http://reviews.llvm.org/D10161)
> 
> @Sanjoy: would you be willing to review this? It looks like you might be
> the person to do it.

Given that this is a major change to SCEV, I think Andy (CC’ed) is the right reviewer.

— Sanjoy


> 
> Also CC'ing Adam as he might be interested as well.
> 
> Thanks,
> Silviu
> 
> 
>>> -----Original Message-----
>>> From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-
>>> bounces at cs.uiuc.edu] On Behalf Of silviu.baranga at arm.com
>>> Sent: 01 June 2015 17:16
>>> To: Silviu Baranga
>>> Cc: llvm-commits at cs.uiuc.edu
>>> Subject: [PATCH] [SCEV][LoopVectorize] Allow ScalarEvolution to make
>>> assumptions about overflows
>>> 
>>> Add a new pass - AssumingScalarEvolution - that extends SCEV, but can
>>> make assumptions and generate code that can check these assumptions.
>>> This pass uses the normal ScalarEvolution pass for anything outside the
>>> current analyzed loop, but uses its own data structures to handle the SCEVs
>>> within the loop. For now, the pass assumes that chrec expressions will not
>>> overflow.
>>> 
>>> The AssumingScalarEvolution pass can add checks for the made
>>> assumptions, so that a loop can be versioned.
>>> 
>>> We use this pass in order to add runtime overflow checks in the Loop
>>> Vectorize pass of expressions which can in theory overflow and would
>>> prevent the vectorization a loop. Also note that the runtime checks will
>>> almost always pass, since having an overflow is usually a sign of a coding
>>> error on the part of user.
>>> 
>>> The main reasons behind inheriting from ScalarEvolution:
>>> Since ScalarEvolution maintains its own cache for various results, making any
>>> assumption would likely require invalidating the entire cache.
>>> 
>>> This way we can use the new pass as an almost drop-in replacement for
>>> ScalarEvolution. The users that are doing a transformation would have to
>>> know about it in order to add the checks.
>>> 
>>> However, there are probably a lot more ways in which this could be
>>> implemented.
>>> 
>>> Any comments are much appreciated!
>>> 
>>> Thanks,
>>> Silviu
>>> 
>>> http://reviews.llvm.org/D10161
>>> 
>>> Files:
>>>  include/llvm/Analysis/LoopAccessAnalysis.h
>>>  include/llvm/Analysis/ScalarEvolution.h
>>>  include/llvm/InitializePasses.h
>>>  lib/Analysis/Analysis.cpp
>>>  lib/Analysis/LoopAccessAnalysis.cpp
>>>  lib/Analysis/ScalarEvolution.cpp
>>>  lib/Transforms/Vectorize/LoopVectorize.cpp
>>>  test/Transforms/LoopVectorize/safegep.ll
>>>  test/Transforms/LoopVectorize/scev-overflow-check.ll
>>>  test/Transforms/LoopVectorize/version-mem-access.ll
>>> 
>>> EMAIL PREFERENCES
>>>  http://reviews.llvm.org/settings/panel/emailpreferences/
> 
> 





More information about the llvm-commits mailing list