[llvm] TTI: Fix special casing vectorization costs of saturating add/sub (PR #97463)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 3 03:55:56 PDT 2024
davemgreen wrote:
> I'm not sure I follow why intrinsics would/should be more precise? In this case, doesn't the intrinsic map directly to the ISD node?
It can if it is legal (say a v4i32 sadd_sat under aarch64), but if it is expand (say a i32 sadd_sat under AArch64) the cost model will just say return SingleCallCost. It scalarizes vectors, and if the node is custom lowered it will just return "LT.first * 2".
https://github.com/llvm/llvm-project/blob/298e292a76289d93f7c1a80c26e354830c6080e4/llvm/include/llvm/CodeGen/BasicTTIImpl.h#L2330
So that's not very accurate, and having a fallback to at least some expansion would seem better for any operation that isn't transformed into a libcall. If an individual target needed something more precise for what it will do, that can be overridden in the target cost model.
https://github.com/llvm/llvm-project/pull/97463
More information about the llvm-commits
mailing list