[llvm] [SLP] Allow targets to add cost for nonstandard conditions (PR #95328)

Jeffrey Byrnes via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 13 13:59:43 PDT 2024


================
@@ -891,6 +891,11 @@ class TargetTransformInfo {
                                            bool Insert, bool Extract,
                                            TTI::TargetCostKind CostKind) const;
 
+  /// Whether or not there is any target-specific condition that imposes an
+  /// overhead for scalarization
+  bool hasScalarizationOverhead(ArrayRef<Value *> VL,
+                                std::pair<bool, bool> &ScalarizationKind) const;
----------------
jrbyrnes wrote:

> What can this express that getOperandsScalarizationOverhead and getScalarizationOverhead do not?

Those functions are used to calculate the cost of the scalarized sequence based on the inserts/extracts needed and the legalization costs based on TLI. We can use either to calculate the cost of scalarization, but we need a mechanism to control whether or not to include this scalarization overhead for a particular tree entry.

Even if we wanted to implement this control in those functions, I think we would still need to query targets as to whether or not there needs to be a cost accounting for the SelectionDAG issue workaround (assuming we could generalize the conditions in which the SelectionDAG issue occurred). Perhaps renaming the hook would help (e.g. hasSelectionDAGScalarizationOverhead)? 

https://github.com/llvm/llvm-project/pull/95328


More information about the llvm-commits mailing list