[llvm-commits] [llvm] r55886 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Evan Cheng evan.cheng at apple.com
Mon Sep 8 01:16:06 PDT 2008


On Sep 7, 2008, at 5:35 PM, Bill Wendling wrote:

> It's not a bug in that this wasn't being done. I was doing a static
> analysis of the DAG combiner and noticed that this wasn't doing what
> the comment claimed it should be doing. If this transformation is
> performed in the selection DAG code, then it should probably be
> removed from here entirely (along with the analogous "ADD"
> transformation). What do you think?

No. The dag combiner xforms can still trigger. The issue is the  
operand can be updated by something like ReplaceAllUsesWith which will  
not transform the uses.

Evan

>
>
> -bw
>
> On Sep 7, 2008, at 5:19 PM, Evan Cheng wrote:
>
>> Is this fixing a bug? getNode should be performing constant folding.
>> See SelectionDAG.cpp line 2441. If somehow that wasn't happening,
>> please fix it there and provide a test case.
>>
>> Thanks,
>>
>> Evan
>>
>> On Sep 7, 2008, at 4:34 AM, Bill Wendling wrote:
>>
>>> Author: void
>>> Date: Sun Sep  7 06:34:47 2008
>>> New Revision: 55886
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=55886&view=rev
>>> Log:
>>> Convert
>>>
>>>  // fold (sub c1, c2) -> c1-c2
>>>
>>> from a no-op into an actual transformation.
>>>
>>> Modified:
>>>  llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
>>>
>>> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=55886&r1=55885&r2=55886&view=diff
>>>
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> = 
>>> ====================================================================
>>> --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
>>> +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Sun Sep  7
>>> 06:34:47 2008
>>> @@ -1111,7 +1111,7 @@
>>>   return DAG.getConstant(0, N->getValueType(0));
>>> // fold (sub c1, c2) -> c1-c2
>>> if (N0C && N1C)
>>> -    return DAG.getNode(ISD::SUB, VT, N0, N1);
>>> +    return DAG.getConstant(N0C->getAPIntValue() - N1C-
>>>> getAPIntValue(), VT);
>>> // fold (sub x, c) -> (add x, -c)
>>> if (N1C)
>>>   return DAG.getNode(ISD::ADD, VT, N0,
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list