[PATCH] D119013: [ArgPromotion][AMDGPU] New MSSA-based function argument promotion pass with input/output argument support
Valery Pykhtin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 18 11:25:40 PST 2022
vpykhtin added inline comments.
================
Comment at: llvm/lib/Transforms/IPO/MSSAArgPromotion.cpp:711
+void ArgumentPromoter::promoteInOutArg(ArgPromotionInfo &ArgInfo,
+ RetValuesMap &RetValues) {
+ SmallDenseMap<BasicBlock *, SmallVector<Instruction *, 4>, 16> MemInsts;
----------------
nikic wrote:
> For the actual promotion, have you considered making use of PromoteMemToReg? Basically, replace the old argument with an alloca that is stored on entry and read on exit, and then run mem2reg on that alloca?
>
> ```
> define i32 @test(i32 %arg) {
> %old.arg = alloca i32
> store i32, i32* %old.arg
> // Code uses old.arg
> %ret = load i32, i32* %old.arg
> ret i32 %ret
> }
> ```
I think this is a good idea to reuse the working code, however I would rather make some sort of refactoring on it than trying to please it :) There is similar code in LICM promoteLoopAccessesToScalars, so it seems we would benefit of such mem2reg framework.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119013/new/
https://reviews.llvm.org/D119013
More information about the llvm-commits
mailing list