[PATCH] D143786: [X86] Add `TuningPreferShiftShuffle` for when Shifts are preferable to shuffles.

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 17 03:51:51 PST 2023


RKSimon added inline comments.


================
Comment at: llvm/lib/Target/X86/X86.td:532
+// shuffle ports that other avx512 targets have so prefer shuffle with
+// shifts/rotate.
+def TuningPreferShiftShuffle : SubtargetFeature<"faster-shift-than-shuffle",
----------------
Maybe rephrase this (e.g. you refer to vprold etc. but not shifts).

"Prefer lowering shuffles on AVX512 targets (e.g. Skylake Server) to shifts/rotate if they can use more ports than regular shuffles." ?


================
Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:38721
+  // We are checking for shuffle match or shift match. Loop twice so we can
+  // order which we try and match first depending on target preference.
+  for (unsigned Order = 0; Order < 2; ++Order) {
----------------
Instead of a loop - why not move the shuffle/shift paths into lambdas and then do this - it should be easier to understand:
```
if (Subtarget.hasFasterShiftThanShuffle()) {
  if (matchUnaryPermuteAsBitShift()) {}
  if (matchUnaryPermuteAsIntShuffle()) {}
} else {
  if (matchUnaryPermuteAsIntShuffle()) {}
  if (matchUnaryPermuteAsBitShift()) {}
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143786



More information about the llvm-commits mailing list