This is an archive of the discontinued LLVM Phabricator instance.

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

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

Details

Summary

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.

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!

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
2330

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

3601

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

7782

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

llvm/test/CodeGen/AArch64/sve-vscale-combine.ll
73

[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,

Francesco

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.