Skip to content

RFC: [TTI] Assume casts between aliasing addrspaces are valid. NFCI. #137969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class TargetTransformInfoImplBase {
virtual bool isAlwaysUniform(const Value *V) const { return false; }

virtual bool isValidAddrSpaceCast(unsigned FromAS, unsigned ToAS) const {
return false;
return addrspacesMayAlias(FromAS, ToAS);
}

virtual bool addrspacesMayAlias(unsigned AS0, unsigned AS1) const {
Expand Down
4 changes: 0 additions & 4 deletions llvm/include/llvm/CodeGen/BasicTTIImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,6 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {

bool isAlwaysUniform(const Value *V) const override { return false; }

bool isValidAddrSpaceCast(unsigned FromAS, unsigned ToAS) const override {
Copy link
Contributor Author

@jayfoad jayfoad Apr 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I don't understand the relationship between BasicTTIImpl and TargetTransformInfoImplBase. I just removed this to stop it from overriding my default implementation in TTIIB.

Copy link
Contributor

@s-barannikov s-barannikov Apr 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TTIImplBase has two derived classes, BasicTTIImpl and NoTTIImpl. The latter is used when the target doesn't provide its own implementation of TTIImplBase (which is usually, if not always, done by inheriting from BasicTTIImpl).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably anything that doesn't make use of TM/TLI (like this and surrounding methods) should only be in TTIImplBase rather than BasicTTIImpl?

return false;
}

bool addrspacesMayAlias(unsigned AS0, unsigned AS1) const override {
return true;
}
Expand Down
21 changes: 0 additions & 21 deletions llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,27 +177,6 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
bool isSourceOfDivergence(const Value *V) const override;
bool isAlwaysUniform(const Value *V) const override;

bool isValidAddrSpaceCast(unsigned FromAS, unsigned ToAS) const override {
// Address space casts must cast between different address spaces.
if (FromAS == ToAS)
return false;

if (FromAS == AMDGPUAS::FLAT_ADDRESS)
return AMDGPU::isExtendedGlobalAddrSpace(ToAS) ||
ToAS == AMDGPUAS::LOCAL_ADDRESS ||
ToAS == AMDGPUAS::PRIVATE_ADDRESS;

if (AMDGPU::isExtendedGlobalAddrSpace(FromAS))
return AMDGPU::isFlatGlobalAddrSpace(ToAS) ||
ToAS == AMDGPUAS::CONSTANT_ADDRESS_32BIT;

if (FromAS == AMDGPUAS::LOCAL_ADDRESS ||
FromAS == AMDGPUAS::PRIVATE_ADDRESS)
return ToAS == AMDGPUAS::FLAT_ADDRESS;

return false;
}

bool addrspacesMayAlias(unsigned AS0, unsigned AS1) const override {
return AMDGPU::addrspacesMayAlias(AS0, AS1);
}
Expand Down