This is an archive of the discontinued LLVM Phabricator instance.

getStrideFromPointer and its helper function from LoopVectorize moved to VectorUtils
ClosedPublic

Authored by ashutosh.nema on Jun 30 2015, 2:07 AM.

Details

Summary

In this change, moved following function from LoopVectorizer to VectorUtils:

a) getGEPInductionOperand
b) stripGetElementPtr
c) getUniqueCastUse
d) getStrideFromPointer

These functions are common between loop vectorizer & upcoming loop versioning for LICM.
Earlier these functions are defined as static functions in LoopVectorize.cpp

For re-usability its good to keep them as utility.

Diff Detail

Repository
rL LLVM

Event Timeline

ashutosh.nema retitled this revision from to getStrideFromPointer and its helper function from LoopVectorize moved to VectorUtils.
ashutosh.nema updated this object.
ashutosh.nema edited the test plan for this revision. (Show Details)
ashutosh.nema set the repository for this revision to rL LLVM.
ashutosh.nema added a subscriber: Unknown Object (MLST).
majnemer added inline comments.
include/llvm/Analysis/VectorUtils.h
23–27

Please sort these.

lib/Analysis/VectorUtils.cpp
18–23

Please sort these.

Sure David will sort these.

Thanks,
Ashutosh

Incorporated comments from David Majnemer.

  • Sorted forward declarations
  • Sorted include files.
hfinkel added a subscriber: hfinkel.Jul 2 2015, 4:02 PM
hfinkel added inline comments.
include/llvm/Analysis/VectorUtils.h
65

I don't understand this comment.

Looking at the implementation, this function returns its first argument. If the argument is a GEP, then it normally returns the operand identified by getGEPInductionOperand. However, if there is some other non-loop-invariant operand, it returns that instead.

69

a case use -> a unique case use, or better, just say:

If a value has only one user that is a CastInst, return it.
74

Don't need to say 'a pointer to', Values are always passed by pointer.

Thanks Hal.
I'll incorporate these comments and soon come up with a new patch.

Regards,
Ashutosh

Incorporated comments from Hal.

Incorporated comments from Hal.

Hi Hal,

Does this looks OK to you ?

Thanks,
Ashutosh

hfinkel accepted this revision.Jul 8 2015, 9:26 PM
hfinkel added a reviewer: hfinkel.

Incorporated comments from Hal.

Hi Hal,

Does this looks OK to you ?

Yes, LGTM (with one small change in a comment requested below).

Thanks,
Ashutosh

include/llvm/Analysis/VectorUtils.h
74

remove "as Value" (I think it reads oddly, as is obvious from the signature)

lib/Analysis/VectorUtils.cpp
283

Same here.

This revision is now accepted and ready to land.Jul 8 2015, 9:26 PM

Incorporated comments from Hal.

Hi Hal,

Does this looks OK to you ?

Yes, LGTM (with one small change in a comment requested below).

Thanks Hal, I'll change it.

Thanks,
Ashutosh

ashutosh.nema edited edge metadata.

Incorporated comments from Hal.

Corrected comments for function 'getStrideFromPointer'.

Hal,

If possible can you please check-in this change, as I don't have check-in permissions.

Thanks,
Ashutosh

hfinkel closed this revision.Jul 11 2015, 3:54 AM

Incorporated comments from Hal.

Corrected comments for function 'getStrideFromPointer'.

Hal,

If possible can you please check-in this change, as I don't have check-in permissions.

r241980.

Thanks,
Ashutosh