Page MenuHomePhabricator

[llvm][CodeGen] DAG Combiner folds for vscale.

Authored by fpetrogalli on Feb 18 2020, 11:29 AM.



This patch simplifies the DAGs generated when using the intrinsic @llvm.vscale.* as follows:

  • Fold (add (vscale * C0), (vscale * C1)) to (vscale * (C0 + C1)).
  • Canonicalize (sub X, (vscale * C)) to (add X, (vscale * -C)).
  • Fold (mul (vscale * C0), C1) to (vscale * (C0 * C1)).
  • Fold (shl (vscale * C0), C1) to (vscale * (C0 << C1)).

The test sve-gep-ll have been updated to reflect the folding introduced by this patch.

Diff Detail

Event Timeline

fpetrogalli created this revision.Feb 18 2020, 11:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 18 2020, 11:29 AM

@fpetrogalli Thank you for working on this! A few nits, but nothing blocking. LGTM!


[nit] Missing opening bracket: (vscale * C0 + C1)) --> (vscale * (C0 + C1))


[nit] Brackets: Fold (mul (vscale * C0), C1) to (vscale * (C0 * C1))) --> Fold (mul (vscale * C0), C1)) to (vscale * (C0 * C1))`


[nit] (shl (vscale * C0), C1) to (vscale * (C0 << C1))) --> (shl (vscale * C0), C1)) to (vscale * (C0 << C1)) :)


[nit] Extra line

fpetrogalli edited the summary of this revision. (Show Details)Feb 21 2020, 9:36 AM
This revision is now accepted and ready to land.Feb 21 2020, 9:50 AM
fpetrogalli marked 4 inline comments as done.

Hi @andwar, I have updated the comments. I have also fixed the sve-gep.ll test, as the changes in the combiner are now folding the multiplying constant inside the vscale node.

Thank you,


fpetrogalli edited the summary of this revision. (Show Details)Feb 21 2020, 9:59 AM
This revision was automatically updated to reflect the committed changes.