[PATCH] D140302: [GlobalISel] [AArch64] Fold G_PTRTOINT(G_CONSTANT)
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 19 07:40:10 PST 2022
arsenm added a comment.
In D140302#4004906 <https://reviews.llvm.org/D140302#4004906>, @arsenm wrote:
> Where are these coming from? I thought we directly emitted pointer constants now?
I think this is special cased for ConstantPointerNull
================
Comment at: llvm/include/llvm/Target/GlobalISel/Combine.td:470
+ [{ return Helper.matchCombineP2IToC(*${root}, ${info}); }]),
+ (apply [{ Helper.applyCombineP2IToC(*${root}, ${info}); }])
+>;
----------------
Should be able to just use replaceInstWithConstant
================
Comment at: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp:2056-2059
+ assert(MI.getOpcode() == TargetOpcode::G_PTRTOINT && "Expected a G_PTRTOINT");
+ const Register SrcReg = MI.getOperand(1).getReg();
+ const MachineInstr *SrcInstr = MRI.getVRegDef(SrcReg);
+ return SrcInstr->getOpcode() == TargetOpcode::G_CONSTANT;
----------------
We already have a matchConstantOp, but that checks for a specific constant. Should have another generic one that checks for any constant
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140302/new/
https://reviews.llvm.org/D140302
More information about the llvm-commits
mailing list