[PATCH] D75501: [DAGCombine] Check the uses of negated floating constant and remove the hack
    Simon Pilgrim via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Tue Mar  3 08:53:28 PST 2020
    
    
  
RKSimon added inline comments.
================
Comment at: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:5570-5575
+  if (!Op.hasOneUse() &&
+      !(Op.getOpcode() == ISD::FP_EXTEND &&
+        isFPExtFree(VT, Op.getOperand(0).getValueType())) &&
+      !(Op.getOpcode() == ISD::ConstantFP &&
+        !getNegatedExpression(Op, DAG, LegalOperations, ForCodeSize)
+             .hasOneUse()))
----------------
spatel wrote:
> This is difficult to read. Please add some intermediate names (maybe as shown below).
> 
> It's not clear to me if that's the logic we want - is this a good or better fix for the problem?
> 
> ```
>   bool IsFreeExtend = Op.getOpcode() == ISD::FP_EXTEND &&
>                       isFPExtFree(VT, Op.getOperand(0).getValueType());
>   bool IsFreeConstant =
>       Op.getOpcode() == ISD::ConstantFP &&
>       !getNegatedExpression(Op, DAG, LegalOperations, ForCodeSize).use_empty();
>   if (!Op.hasOneUse() && !IsFreeExtend && !IsFreeConstant)
>     return NegatibleCost::Expensive;
> 
> 
> ```
```
if (!Op.hasOneUse()) {
  bool IsFreeExtend = Op.getOpcode() == ISD::FP_EXTEND &&
                    isFPExtFree(VT, Op.getOperand(0).getValueType());
  if (!IsFreeExtend)
    return NegatibleCost::Expensive;
  bool IsFreeConstant = Op.getOpcode() == ISD::ConstantFP &&
        !getNegatedExpression(Op, DAG, LegalOperations, ForCodeSize).use_empty();
  if (!IsFreeConstant)
    return NegatibleCost::Expensive;
}
```
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75501/new/
https://reviews.llvm.org/D75501
    
    
More information about the llvm-commits
mailing list