Page MenuHomePhabricator

[RISCV][TTI] Account for constant materialization cost when costing airthmetic operations
ClosedPublic

Authored by reames on Nov 29 2022, 12:28 PM.

Details

Summary

At the IR level, we generally assume that constants are free to materialize. However, for RISCV due to some quirks of the ISA, materializing arbitrary constants can be rather expensive. We frequently fallback to constant pool loads.

We've been slowly moving in the direction of modeling the cost of the remat as part of the instruction cost. This has the effect of disincentivizing vectorization - mostly SLP - when we'd have to materialize an expensive constant.

We need better modeling of which constants are expensive and not, but the moment let's be consistent with how we model arithmetic and memory instructions. The difference between the two is that arithmetic can sometimes fold a splat operation which stores can not.

Diff Detail

Event Timeline

reames created this revision.Nov 29 2022, 12:28 PM
reames requested review of this revision.Nov 29 2022, 12:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 29 2022, 12:28 PM

arithmetic is misspelled in the title

craig.topper added inline comments.Nov 29 2022, 4:00 PM
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
1087

Why 12 bit? If we're referring to vector instructions its 5 bits isn't it?

asb added a comment.Nov 30 2022, 5:24 AM

I think I agree with Craig's comment (or have the same misunderstanding, suggesting the code comment could be clarified). Otherwise, LGTM (leaving of the green tick just because I think it needs that point resolved with Craig).

reames added inline comments.Nov 30 2022, 7:20 AM
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
1087

This was a typo on my part. Was thinking about memory addressing for scalars at the same time, and the 12 bit got copied over. Fixed in the version I'll land.

This revision was not accepted when it landed; it landed in state Needs Review.Nov 30 2022, 7:20 AM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.