[LLVMdev] DependenceAnalysis and PR14241
Hal Finkel
hfinkel at anl.gov
Fri Nov 2 12:13:40 PDT 2012
----- Original Message -----
> From: "Preston Briggs" <preston.briggs at gmail.com>
> To: "Tobias Grosser" <tobias at grosser.es>
> Cc: "Hal Finkel" <hfinkel at anl.gov>, "Benjamin Kramer" <benny.kra at gmail.com>, "LLVM Developers Mailing List"
> <llvmdev at cs.uiuc.edu>
> Sent: Friday, November 2, 2012 1:40:16 PM
> Subject: Re: [LLVMdev] DependenceAnalysis and PR14241
>
> Here's the current code (abstracted a bit)
>
>
>
> const Instruction *Src,
> const Instruction *Dst,
> // make sure they are loads and stores, then
>
> const Value *SrcPtr = getPointerOperand(Src); // hides a little
> casting, then Src->getPointerOperand
> const Value *DstPtr = getPointerOperand(Dst); // ditto
> // see how underlying objects alias, then
>
> const GEPOperator *SrcGEP = dyn_cast<GEPOperator>(SrcPtr);
> const GEPOperator *DstGEP = dyn_cast<GEPOperator>(DstPtr);
>
>
> After that, most everything is done by disassembling the SrcGEP and
> DstGEP.
> The conservative approach would be to make sure SrcPtr and DstPtr are
> both loop invariant.
>
>
> I'm not sure what you're suggesting. How to I pass one (both?) of
> these pointers to SCEV?
>
const Instruction *Src;
const Instruction *Dst;
...
const Value *SrcPtr = getPointerOperand(Src);
const Value *DstPtr = getPointerOperand(Dst);
...
SCEV *SrcPtrSCEV = SE->getSCEV(SrcPtr);
SCEV *DstPtrSCEV = SE->getSCEV(DstPtr);
...
SCEV *SrcPtrBaseSCEV = SE->getPointerBase(SrcPtrSCEV);
SCEV *DstPtrBaseSCEV = SE->getPointerBase(DstPtrSCEV);
...
SCEV *SrcPtrOffset = SE->getMinusSCEV(SrcPtrSCEV, SrcPtrBaseSCEV);
SCEV *DstPtrOffset = SE->getMinusSCEV(DstPtrSCEV, DstPtrBaseSCEV);
[these expressions may be the answer you'd like multiplied by the size of the type]
...
if (isa<SCEVAddRecExpr>(SrcPtrOffset))
cast<SCEVAddRecExpr>(SrcPtrOffset)->evaluateAtIteration(...)
// same with Dst
I think something like this will do what you need.
-Hal
>
> Thanks,
> Preston
>
>
>
>
>
>
>
>
>
> On Fri, Nov 2, 2012 at 11:08 AM, Tobias Grosser < tobias at grosser.es >
> wrote:
>
>
>
>
> On 11/02/2012 11:02 AM, Hal Finkel wrote:
>
>
> ----- Original Message -----
>
>
> From: "Tobias Grosser" < tobias at grosser.es >
> To: "preston briggs" < preston.briggs at gmail.com >
> Cc: "Benjamin Kramer" < benny.kra at gmail.com >, "LLVM Developers
> Mailing List" < llvmdev at cs.uiuc.edu >
> Sent: Friday, November 2, 2012 12:56:53 PM
> Subject: Re: [LLVMdev] DependenceAnalysis and PR14241
>
> On 11/02/2012 10:21 AM, Preston Briggs wrote:
>
>
>
> My initial guess is that a conservative fix is quick and small
> (make
> sure the underlying pointers are loop invariant, otherwise give
> up). A
> better approach would be to somehow turn code like the example into
> array references that can be analyzed. I'll need to think about
> this and
> do some reading.
>
> Hi Preston,
>
> I looked at this test case. I am not sure what you are exactly doing,
> but I have the feeling you start from the getelementptr instruction.
> If
> you directly pass the pointer that is pointed to by the loads and
> stores
> to SCEV, there should just be a single base pointer %s in the
> resulting
> SCEVS. You can then extract this base pointer, subtract it from the
> scev
> and analyze the remaining scev as subscript. The base pointer in this
> test case is loop invariant.
>
> Does const SCEV *getPointerBase(const SCEV *V) do this?
>
> It give you the base pointer. Yes.
>
> Tobi
>
>
--
Hal Finkel
Postdoctoral Appointee
Leadership Computing Facility
Argonne National Laboratory
More information about the llvm-dev
mailing list