Skip to content

Commit aea773c

Browse files
committed
[AMDGPU] Allow casts between the Global and Constant Addr Spaces in isValidAddrSpaceCast
So far, isValidAddrSpaceCast only allows casts to the flat address space and between the constant(32) address spaces. It does not allow casting between the global and constant address spaces, even though the constant AS is only an alias for the global AS. That affects, e.g., the lowering of memmoves from the constant to the global address space in LowerMemIntrinsics, since that requires aliasing address spaces to be castable. This patch allows such casts. It also includes a memmove test that would crash with the previous implementation because the memmove IR lowering would not be applicable for the move from constant AS to global AS.
1 parent 37ad65f commit aea773c

File tree

2 files changed

+2339
-3
lines changed

2 files changed

+2339
-3
lines changed

llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,12 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
187187
}
188188
return false;
189189
}
190-
if ((FromAS == AMDGPUAS::CONSTANT_ADDRESS_32BIT &&
191-
ToAS == AMDGPUAS::CONSTANT_ADDRESS) ||
192-
(FromAS == AMDGPUAS::CONSTANT_ADDRESS &&
190+
if (FromAS != ToAS &&
191+
(FromAS == AMDGPUAS::GLOBAL_ADDRESS ||
192+
FromAS == AMDGPUAS::CONSTANT_ADDRESS ||
193+
FromAS == AMDGPUAS::CONSTANT_ADDRESS_32BIT) &&
194+
(ToAS == AMDGPUAS::GLOBAL_ADDRESS ||
195+
ToAS == AMDGPUAS::CONSTANT_ADDRESS ||
193196
ToAS == AMDGPUAS::CONSTANT_ADDRESS_32BIT))
194197
return true;
195198
return false;

0 commit comments

Comments
 (0)