This is an archive of the discontinued LLVM Phabricator instance.

[SVE] Fix the FP arithmetic instruction costs for SVE
ClosedPublic

Authored by david-arm on Aug 31 2021, 6:27 AM.

Details

Summary

Several FP instructions (fadd, fsub, etc.) were incorrectly assigned
a higher cost for SVE because they have custom lowering, however we
know they are legal. This patch explicitly assigns a cost of 2 to
these opcodes.

Tests added here:

Analysis/CostModel/AArch64/arith-fp-sve.ll

Diff Detail

Event Timeline

david-arm created this revision.Aug 31 2021, 6:27 AM
david-arm requested review of this revision.Aug 31 2021, 6:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2021, 6:27 AM
sdesmalen added inline comments.Aug 31 2021, 6:32 AM
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
1405

This condition is missing !Ty->getScalarType()->isFP128Ty(), and if you add it, the if-statement can be merged with the one above:

..
case ISD::FNEG:
  if (!Ty->getScalarType()->isFP128Ty())
    return (Cost + 2) * LT.first;
david-arm updated this revision to Diff 369877.Sep 1 2021, 1:07 AM
  • Coalesced the checks in getArithmeticInstrCost, as well as fixed up some other tests I'd missed.
sdesmalen accepted this revision.Sep 1 2021, 6:36 AM
This revision is now accepted and ready to land.Sep 1 2021, 6:36 AM
Matt added a subscriber: Matt.Sep 1 2021, 7:52 AM
This revision was landed with ongoing or failed builds.Sep 2 2021, 1:56 AM
This revision was automatically updated to reflect the committed changes.