[PATCH] D152659: [LV] Add IRBuilder folder to simplify GEP x, 0.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 29 07:22:02 PDT 2023


fhahn added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:480
+/// Folder to simplify common patterns generated by LV codegen.
+class LVFolder final : public ConstantFolder {
+  void anchor() override {}
----------------
fhahn wrote:
> nikic wrote:
> > Any reason to base this on ConstantFolder rather than TargetFolder?
> No particular reason, it could definitely also be TargetFolder. In general, I think those sort of lightweight simplifications could be beneficial for most/all users of `ConstantFolder/TargetFolder`, so it might make sense to also use them there eventually?
Changed to TargetFolder.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:9751
       Value *Increment = createStepForVF(Builder, IndexTy, State.VF, Part);
       PartPtr = Builder.CreateGEP(ScalarDataTy, Ptr, Increment, "", InBounds);
     }
----------------
Ayal wrote:
> Is this (the only place) where the redundant gep-with-zero are generated?
> 
> Would be good to ensure recipes are (more) aware of the code they generate, and potentially account for it cost-wise, rather than folding this inside IRBuilder?
Redundant GEPs can also at least be generated in the `if()` part and in `vectorizeInterleaveGroup`.  Agreed that it would be good to include this during cost estimates once we do it per recipe; but I *think* then we can just ignore such redundant GEPs during the cost calculation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152659



More information about the llvm-commits mailing list