[PATCH] D148841: [LV] Use SCEV for uniformity analysis across VF

Ayal Zaks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 29 13:49:14 PDT 2023


Ayal accepted this revision.
Ayal added a comment.
This revision is now accepted and ready to land.

This looks good to me, thanks!
Adding last couple of minor nits.



================
Comment at: llvm/lib/Analysis/LoopAccessAnalysis.cpp:2565
+  /// which are not loop invariant require operations to strip out the lowest
+  /// bits. For now just look for UDivs and use it to avoid re-writing UDIV-free
+  /// expressions for other lanes to limit compile time.
----------------



================
Comment at: llvm/lib/Analysis/LoopAccessAnalysis.cpp:2575
+      : SCEVRewriteVisitor(SE), StepMultiplier(StepMultiplier), Offset(Offset),
+        TheLoop(TheLoop) {}
+
----------------
Constructor can now also be private.


================
Comment at: llvm/test/Transforms/LoopVectorize/X86/uniform_mem_op.ll:427
+; CHECK-NEXT:    [[TMP39]] = add <4 x i32> [[VEC_PHI6]], [[TMP35]]
+; CHECK-NEXT:    [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 16
+; CHECK-NEXT:    [[VEC_IND_NEXT]] = add <4 x i64> [[STEP_ADD2]], <i64 4, i64 4, i64 4, i64 4>
----------------
fhahn wrote:
> Ayal wrote:
> > fhahn wrote:
> > > Ayal wrote:
> > > > note: VF=4 is mandated, previous UF=2 decision with 8 loads is now UF=4 with 4 (uniform) loads & broadcasts.
> > > > 
> > > > The load from test_base[i/8] could further fold two 'parts' of VF=4 together, as it is uniform across VF=8 / VF=4,UF=2.
> > > > Worth leaving behind some **assume**, if not folding directly? I.e., record the largest VF for which uniformity was detected, even if a smaller VF is selected.
> > > > Worth optimizing the analysis across VF's, i.e., if a value is known not to be uniform for VF avoid checking for 2*VF? OTOH, if a value is known to be uniform for VF, check only two SCEVs for 2*VF?
> > > > The load from test_base[i/8] could further fold two 'parts' of VF=4 together, as it is uniform across VF=8 / VF=4,UF=2.
> > > 
> > > I think that would be good as follow-up.
> > > 
> > > > Worth optimizing the analysis across VF's, i.e., if a value is known not to be uniform for VF avoid checking for 2*VF
> > > 
> > > I was thinking about evaluating something like that as follow-up optimization. WDYT?
> > Sure, TODOs can be added to record potential follow-ups.
> > 
> > Note also that uniformity could be improved beyond comparing equal SCEV expressions, by using Divergence Analysis which propagates uniformity also through uniform branches.
> Added a TOOD, thanks!
Thanks! Plus following-up with D151658!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148841



More information about the llvm-commits mailing list