This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][SVEIntrinsicOpts] Fix: predicated SVE mul/fmul are not commutative
ClosedPublic

Authored by igor.kirillov on Nov 25 2021, 3:42 AM.

Details

Summary

We can not swap multiplicand and multiplier because the sve intrinsics
are predicated. Imagine lanes in vectors having the following values:

pg = 0
multiplicand = 1 (from dup)
multiplier = 2

The resulting value should be 1, but if we swap multiplicand and multiplier it will become 2,
which is incorrect.

Diff Detail

Event Timeline

igor.kirillov created this revision.Nov 25 2021, 3:42 AM
igor.kirillov requested review of this revision.Nov 25 2021, 3:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 25 2021, 3:42 AM
mgabka added a subscriber: mgabka.Nov 25 2021, 7:09 AM
paulwalker-arm accepted this revision.Nov 25 2021, 8:49 AM
paulwalker-arm added inline comments.
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
837

Before committing can you please update this comment and the one within the else if block to reflect the now restricted use case of [f]mul pg %n, (dupx 1) => %n.

This revision is now accepted and ready to land.Nov 25 2021, 8:49 AM
Matt added a subscriber: Matt.Nov 25 2021, 8:53 AM

Update comment

igor.kirillov marked an inline comment as done.Nov 25 2021, 11:43 AM