[PATCH] D109528: [AArch64][GlobalISel] Add a new reassociation for G_PTR_ADDs.
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 13 01:39:09 PDT 2021
foad added a comment.
Instead of optimizing three specific cases do you think it's worth doing something more general, like traversing a whole tree of G_PTR_ADD and G_ADD expressions, collecting the pointers / ints / constant-offsets, and then reassembling them in an optimal order?
================
Comment at: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp:4188
+ // 3) Move a constant from the LHS of an inner op to the RHS of the outer.
+ // G_PTR_ADD (G_PTR_ADD X, C), Y) -> (G_PTR_ADD (G_PTR_ADD(X, Y), C)
+ // iif (G_PTR_ADD X, C) has one use.
----------------
Mismatched parentheses on this line.
================
Comment at: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp:4201
- auto NewBase =
- Builder.buildPtrAdd(PtrTy, Src1Reg, RHS->getOperand(1).getReg());
- Observer.changingInstr(MI);
- MI.getOperand(1).setReg(NewBase.getReg(0));
- MI.getOperand(2).setReg(RHS->getOperand(2).getReg());
- Observer.changedInstr(MI);
- };
- } else {
- // Try to match example 2.
- Register LHSSrc1 = LHS->getOperand(1).getReg();
- Register LHSSrc2 = LHS->getOperand(2).getReg();
- auto C1 = getConstantVRegVal(LHSSrc2, MRI);
- if (!C1)
- return false;
- auto C2 = getConstantVRegVal(Src2Reg, MRI);
- if (!C2)
- return false;
+ // Try to match example 1).
+ if (matchReassocConstantInnerRHS(PtrAdd, RHS, MatchInfo))
----------------
Stray parenthesis.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109528/new/
https://reviews.llvm.org/D109528
More information about the llvm-commits
mailing list