[PATCH] D76434: [SCEV] Query expanded immediate cost at minsize

Sam Parker via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 14 07:37:40 PDT 2020


samparker added a comment.

> This really needs refactoring/generalization.

I will try...

> Have you checked what happens if you simply make isHighCostExpansionHelper() always return true for -Oz? :)

I thought I did, but actually it was just for rewriting loop exit values... I will run the numbers though! But I'm also interested in whether this can still be beneficial for execution speed too.



================
Comment at: llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp:2364
+    if (CostKind == TTI::TCK_CodeSize)
+      costNAryImmOperands(NAry);
+    else
----------------
lebedev.ri wrote:
> samparker wrote:
> > Now I notice that I wouldn't have been handling AddRec expressions... So should these operands be added to the worklist for both Add and Mul or would just Add be okay?
> Given `A + B*x`, you'd want to model `A` as being at index 1,
> and `B` as being part of multipler (again, at index 1.
> 
> And for higher orders `A + B*x + C*x^2`, again, `B` and `C` are part of multiply,
> and it should be modelled as `(B*x + C*x^2) + A`.
> 
> So i think the generalization is that all nary operands except the first one are at index 1 of `mul`,
> and the first nary operand is at index 1 of `add`.
Okay, thanks.


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

https://reviews.llvm.org/D76434



More information about the llvm-commits mailing list