[PATCH] TTI: Honour cost model for estimating cost of vector-intrinsic and calls.

Michael Zolotukhin mzolotukhin at apple.com
Fri Mar 6 10:59:13 PST 2015


================
Comment at: include/llvm/CodeGen/BasicTTIImpl.h:548
@@ +547,3 @@
+      if (ScalarCalls == 1)
+        return 10;
+
----------------
hfinkel wrote:
> Why are you changing the default cost for intrinsics from one to ten? I believe it used to be one, and that was because we made an explicit decision to make intrinsics default to something cheap.
I made two changes here:

1) Change `10 * Cost * Num` to `ScalarCalls * ScalarCost + ScalarizationOverhead`. I believe factor `10` initially was used to model the scalarization overhead, but now we can estimate it more accurately.

2) Change `ScalarCalls + ScalarizationCost` to `ScalarCalls*10 + ScalarizationCost`. To me it looked a bit inconsistent: when an unknown intrinsic has a vector type, we returned `ScalarCalls + ScalarizationCost` (effectively, `ScalarCost` is implicitly assumed to be 1). However, for known intrinsics scalar cost is 10 (unless the operation is legal and we know exact cost). I can revert this change, but the original code just looked a bit odd to me.

However, I can find explanation like "we expect all unknown intrinsics to be lowered to somewhat cheap (cost=1), in contrast to the listed ones, which will definitely be lowered to an expensive libcall (cost=10)". If that's the case, I agree that the original code is correct.

http://reviews.llvm.org/D8096

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list