[PATCH] D77646: [PowerPC] Fold vector merges of swapped vectors to merge the opposite half

Stefan Pintilie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 6 13:00:45 PDT 2020


stefanp accepted this revision as: stefanp.
stefanp added a comment.
This revision is now accepted and ready to land.

This patch LGTM.
I have a few minor comments but that is it.



================
Comment at: llvm/lib/Target/PowerPC/PPCMIPeephole.cpp:274
+  unsigned Opc = MI->getOpcode();
+  if (Opc == PPC::XXPERMDIs && MI->getOperand(2).getImm() == 2)
+    return true;
----------------
What about `XXSLDWIs` here? It's the same as `XXSLDWI` but we know the two inputs are the same.


================
Comment at: llvm/lib/Target/PowerPC/PPCMIPeephole.cpp:313
+    return Imm == 0 || Imm == 3;
+  }
+  return false;
----------------
Question:
I assume that trivial instructions such as: `XXLEQV` and `XXLORC` are not worth adding because we will never see them with identical inputs. Basically `XXLEQV` with `MI->getOperand(1).getReg() == MI->getOperand(2).getReg()` is the same as `XXLEQVOnes` so we will never see that by itself.


================
Comment at: llvm/lib/Target/PowerPC/PPCMIPeephole.cpp:336
+  LLVM_DEBUG(Copy->dump());
+  (void)Copy;
+  return DestReg;
----------------
Is this last line there so that the compiler does not complain about having `Copy` defined but not used when we don't have debug enabled?


================
Comment at: llvm/test/CodeGen/PowerPC/merge_of_swap.ll:8
+; RUN: FileCheck %s --check-prefix=CHECK-P9
+define dso_local <4 x i32> @mrglb_self(<8 x i8>* nocapture readonly %c) local_unnamed_addr #0 {
+; CHECK-P8-LABEL: mrglb_self:
----------------
nit: 
I don't think we need the `#0`.
Also can you add a couple of sentences to explain that this test checks that we want to remove swaps that feed merges when we know the input to the swap is symmetrical.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77646





More information about the llvm-commits mailing list