This is an archive of the discontinued LLVM Phabricator instance.

LoopStrengthReduce: Try to pass address space to isLegalAddressingMode
ClosedPublic

Authored by arsenm on Jun 5 2015, 5:09 PM.

Details

Reviewers
hfinkel
Summary

This seems to only work some of the time. In some situations,
this seems to use a nonsensical type and isn't actually aware of the
memory being accessed. e.g. if branch condition is an icmp of a pointer,
it checks the addressing mode of i1.

Diff Detail

Event Timeline

arsenm updated this revision to Diff 27243.Jun 5 2015, 5:09 PM
arsenm retitled this revision from to LoopStrengthReduce: Try to pass address space to isLegalAddressingMode .
arsenm updated this object.
arsenm edited the test plan for this revision. (Show Details)
arsenm added a subscriber: Unknown Object (MLST).

Would it be better to do this refactoring by making some pair<Type *, AddressSpace> and passing that around instead of adding the extra AddressSpace parameter everywhere? If the underlying premise is that the Type is meaningless without the address space, I'd prefer to just force them to live together.

lib/Transforms/Scalar/LoopStrengthReduce.cpp
3180

I'd rather not end up with code like this. It would be better to define some global constant InvalidAddressSpace (or similar) that is equal to ~0u, and then use that.

arsenm added inline comments.Jun 26 2015, 3:24 PM
lib/Transforms/Scalar/LoopStrengthReduce.cpp
3180

Where should this be defined? I'm not sure where would be a good place for it

arsenm updated this revision to Diff 28606.Jun 26 2015, 3:39 PM

Use struct of memory type and address space

hfinkel added inline comments.Jul 26 2015, 5:43 AM
lib/Transforms/Scalar/LoopStrengthReduce.cpp
106

There's no need for this to be a pre-processor macro, we can say:

static const unsigned UnknownAddressSpace = ~0u;

and make it a member of MemAccessTy.

Also, please comment that this is used to initialize the AddressSpace member of MemAccessTy, for non-pointer types, but that ~0u is actually a legal address space value (unless we want to change that, but that requires updating the AsmParser, etc.).

3180

MemAccessTy(nullptr, UNKNOWN_ADDRESS_SPACE) -> MemAccessTy()

(or do you want MemAccessTy::getUnknown()?)

arsenm added inline comments.Jul 27 2015, 12:13 PM
lib/Transforms/Scalar/LoopStrengthReduce.cpp
106

Is there some header where this should go? There are a few other places that call isLegalAddressingMode in other passes where it's unclear what the address space would mean.

Address spaces > 24 bits are already disallowed by the code in other places although I'm not sure this is documented anywhere.

arsenm added inline comments.Jul 27 2015, 1:02 PM
lib/Transforms/Scalar/LoopStrengthReduce.cpp
3180

This is nullptr because this is what it was using previously for the type. The existing code in some places uses void type and others use nullptr, and I'm not sure if there's a significant distinction between the uses. Changing this should be a separate change if worth doing

arsenm updated this revision to Diff 30725.Jul 27 2015, 1:09 PM

Don't use macro

hfinkel accepted this revision.Aug 9 2015, 9:10 PM
hfinkel added a reviewer: hfinkel.

Either the absence of the address spaces below are mistakes, or please add a comment explaining why the address space should not be passed there. Otherwise, LGTM.

lib/Transforms/Scalar/LoopStrengthReduce.cpp
2185

Why are you not passing the address space here?

2190

And here?

This revision is now accepted and ready to land.Aug 9 2015, 9:10 PM
arsenm closed this revision.Aug 14 2015, 5:54 PM
arsenm marked 2 inline comments as done.

Good catches. r245137