[PATCH] D127676: [ARM] Allow distributing postinc with PHI uses

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 13 11:12:27 PDT 2022


dmgreen created this revision.
dmgreen added reviewers: SjoerdMeijer, samtebbs, NickGuy, dpenry.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: All.
dmgreen requested review of this revision.
Herald added a project: LLVM.

Although this doesn't usually come up, we can have uses of the BaseAccess of a distributed postinc being a PHI. This doesn't need the usual dominance check as we will dominate along the phi edge, allowing us to still create a postinc load/store.


https://reviews.llvm.org/D127676

Files:
  llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
  llvm/test/CodeGen/Thumb2/mve-pipelineloops.ll


Index: llvm/test/CodeGen/Thumb2/mve-pipelineloops.ll
===================================================================
--- llvm/test/CodeGen/Thumb2/mve-pipelineloops.ll
+++ llvm/test/CodeGen/Thumb2/mve-pipelineloops.ll
@@ -45,8 +45,7 @@
 ; CHECK-NEXT:    vmlsldava.s16 r4, r7, q0, q1
 ; CHECK-NEXT:    vldrh.u16 q0, [r0], #32
 ; CHECK-NEXT:    vldrh.u16 q3, [r1, #-16]
-; CHECK-NEXT:    vldrh.u16 q1, [r1]
-; CHECK-NEXT:    adds r1, #32
+; CHECK-NEXT:    vldrh.u16 q1, [r1], #32
 ; CHECK-NEXT:    le lr, .LBB0_2
 ; CHECK-NEXT:  .LBB0_3:
 ; CHECK-NEXT:    mov.w lr, #14
Index: llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
===================================================================
--- llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
+++ llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
@@ -2899,7 +2899,8 @@
     // Make sure that Increment has no uses before BaseAccess.
     for (MachineInstr &Use :
         MRI->use_nodbg_instructions(Increment->getOperand(0).getReg())) {
-      if (!DT->dominates(BaseAccess, &Use) || &Use == BaseAccess) {
+      if (&Use == BaseAccess || (Use.getOpcode() != TargetOpcode::PHI &&
+                                 !DT->dominates(BaseAccess, &Use))) {
         LLVM_DEBUG(dbgs() << "  BaseAccess doesn't dominate use of increment\n");
         return false;
       }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127676.436481.patch
Type: text/x-patch
Size: 1312 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220613/02cc8e3a/attachment.bin>


More information about the llvm-commits mailing list