[PATCH] D87140: [GlobalISel] Avoid making G_PTR_ADD with nullptr

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 16 06:13:09 PDT 2020


arsenm added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUCombine.td:40
 
+def add_with_zero: GICombineRule<
+  (defs root:$root),
----------------
arsenm wrote:
> This should go in the generic combiner
ptr_add


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUCombine.td:40-45
+def add_with_zero: GICombineRule<
+  (defs root:$root),
+  (match (wip_match_opcode G_PTR_ADD):$root,
+    [{ return matchAddZero(*${root}, MRI, *MF, Helper); }]),
+  (apply [{ applyAddZero(*${root}); }])>;
+
----------------
This should go in the generic combiner


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUPreLegalizerCombiner.cpp:45
+static void applyAddZero(MachineInstr &MI) {
+  MachineIRBuilder B(MI);
+  B.buildIntToPtr(MI.getOperand(0), MI.getOperand(2));
----------------
Should not construct a local MachineIRBuilder


================
Comment at: llvm/test/CodeGen/AMDGPU/GlobalISel/combine-add-nullptr.mir:52-53
+    %8:_(s32) = G_PTRTOINT %6(p3)
+    %9:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.readfirstlane), %8(s32)
+    $sgpr0 = COPY %9(s32)
+    SI_RETURN_TO_EPILOG implicit $sgpr0
----------------
Can simplify these out of the test


================
Comment at: llvm/test/CodeGen/AMDGPU/GlobalISel/combine-add-nullptr.mir:56
+
+...
----------------
Should add vector test


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87140/new/

https://reviews.llvm.org/D87140



More information about the llvm-commits mailing list