[PATCH] D77993: [NFC][DAGCombine] Change the value of NegatibleCost to make it align with the semantics

Qing Shan Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 14 19:36:10 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGc9f9c79c5a48: [NFC][DAGCombine] Change the value of NegatibleCost to make it align with theā€¦ (authored by steven.zhang).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77993/new/

https://reviews.llvm.org/D77993

Files:
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp


Index: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -5671,10 +5671,10 @@
                                         ForCodeSize, Depth + 1);
     NegatibleCost V1 = getNegatibleCost(Op.getOperand(1), DAG, LegalOperations,
                                         ForCodeSize, Depth + 1);
-    NegatibleCost V01 = std::max(V0, V1);
+    NegatibleCost V01 = std::min(V0, V1);
     if (V01 == NegatibleCost::Expensive)
       return NegatibleCost::Expensive;
-    return std::max(V01, V2);
+    return std::min(V01, V2);
   }
 
   case ISD::FP_EXTEND:
@@ -5776,7 +5776,7 @@
     SDValue NegZ = getNegatedExpression(Z, DAG, LegalOps, OptForSize, Depth);
     NegatibleCost CostX = getNegatibleCost(X, DAG, LegalOps, OptForSize, Depth);
     NegatibleCost CostY = getNegatibleCost(Y, DAG, LegalOps, OptForSize, Depth);
-    if (CostX > CostY) {
+    if (CostX <= CostY) {
       // fold (fneg (fma X, Y, Z)) -> (fma (fneg X), Y, (fneg Z))
       SDValue NegX = getNegatedExpression(X, DAG, LegalOps, OptForSize, Depth);
       return DAG.getNode(Opcode, DL, VT, NegX, Y, NegZ, Flags);
Index: llvm/include/llvm/CodeGen/TargetLowering.h
===================================================================
--- llvm/include/llvm/CodeGen/TargetLowering.h
+++ llvm/include/llvm/CodeGen/TargetLowering.h
@@ -257,9 +257,9 @@
 
   /// Enum that specifies when a float negation is beneficial.
   enum class NegatibleCost {
-    Expensive = 0,  // Negated expression is more expensive.
+    Cheaper = 0,    // Negated expression is cheaper.
     Neutral = 1,    // Negated expression has the same cost.
-    Cheaper = 2     // Negated expression is cheaper.
+    Expensive = 2   // Negated expression is more expensive.
   };
 
   class ArgListEntry {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77993.257589.patch
Type: text/x-patch
Size: 1915 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200415/3ed588d2/attachment.bin>


More information about the llvm-commits mailing list