This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU][AMDGPULowerKernelAttributes] Use stripAndAccumulateConstantOffset
AbandonedPublic

Authored by jmmartinez on Oct 5 2022, 5:33 AM.

Details

Reviewers
cfang
Summary

This removes the need to handle explicitely the presence or absence of bitcasts when typed pointers are used. It also takes into account the case where we have more than one use of load(call @llvm.amdgc.implicitarg.ptr())

Diff Detail

Event Timeline

jmmartinez created this revision.Oct 5 2022, 5:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 5 2022, 5:33 AM
jmmartinez requested review of this revision.Oct 5 2022, 5:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 5 2022, 5:33 AM
jmmartinez updated this revision to Diff 465353.Oct 5 2022, 5:43 AM
  • Handle non-inbounds GEP

Some drive by comments

llvm/lib/Target/AMDGPU/AMDGPULowerKernelAttributes.cpp
118

This function and uses are unrelated.

123

This does break with the "unique" property below. Two users, one simple one not, will result in a load. Is that expected?

139

A unique load reached via select or phi will not be detected. UniqueLoad && UniqueLoad != L can help with that.

Style: I'd remove braces for single return conditionals.

141

I would use the Attributor::checkForAllUses, also unsure why the loads need to be unique. Depending on the call AAPointerInfo would allow you to handle way more things without any of this manual tracing. Either seems to be a useful rewrite beyond the scope of this. Feel free to ignore for now.

jmmartinez updated this revision to Diff 465364.Oct 5 2022, 6:14 AM
  • Rename getUniqueLoadUser into getUniqueSimpleLoadUser.
  • Consider the case where the UniqueLoad is 'found' twice.
  • Style
llvm/lib/Target/AMDGPU/AMDGPULowerKernelAttributes.cpp
118

I'm sorry, I do not understand this remark. What do you mean?

123

It's ok if there is another non-simple load.

In fact, this pass could be modified to support multiple loads. My guess is that for simplicity only one is supported for the moment.

I renamed the function instead into getUniqueSimpleLoadUser

141

I'm not familiar with it. I'm going to take a look at it. Thanks!

jdoerfert added inline comments.Oct 5 2022, 6:19 AM
llvm/lib/Target/AMDGPU/AMDGPULowerKernelAttributes.cpp
118

The commit is about the load tracking and stripping. This change (outlining getBasePtrIntrinsic and using it) is unrelated to the content/description of the patch. Make it two patches instead.

jmmartinez added inline comments.Oct 5 2022, 6:50 AM
llvm/lib/Target/AMDGPU/AMDGPULowerKernelAttributes.cpp
118

Oh! I agree. I created https://reviews.llvm.org/D135266 for that change.

arsenm added a comment.Oct 5 2022, 7:53 AM

Needs a test for this multiple load case

jmmartinez updated this revision to Diff 465400.Oct 5 2022, 7:56 AM
  • Rebase and move annonymous namespace to remove static keyword
jmmartinez marked 4 inline comments as done.Oct 5 2022, 7:57 AM
  • Extend AMDGPULowerKernelAttributes to handle multiple occurrences of the attributes in the same function
  • Fix reminder indices in test
  • Add test-cases with multiple users, and more than one in a single function
jmmartinez abandoned this revision.Nov 22 2022, 4:51 AM

To split into smaller changes later.