[PATCH] D115724: [InstCombine] Fold for masked scatters to a uniform address

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 14 08:31:10 PST 2021


sdesmalen added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp:378
+  // uniform store and can be folded.
+  if (ConstMask->isAllOnesValue())
+    if (auto *Splat = getSplatValue(II.getArgOperand(1))) {
----------------
david-arm wrote:
> sdesmalen wrote:
> > I think you can distinguish two cases here:
> > 1. The pointer is a splat(), the value is not a splat, the mask is an all-active mask.
> > 2. The pointer is a splat(), the value is a splat(), the mask is not all-inactive (but not necessarily all active).
> > 
> > For 2, you can extract any lane instead of the last lane.
> For 2, I don't think you can extract any lane - it has to be the last active lane otherwise it's not functionally correct since that's the only thing that matches the scalar equivalent? The trouble with extracting the last active lane is that the resulting code is potentially going to be worse than a scatter I think? I don't think there is a trivial way in LLVM IR to ask for the last active lane.
If all lanes contain the same value (the value is a splat()), and at least one lane is active, why couldn't you extract any lane?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115724



More information about the llvm-commits mailing list