[llvm] r269236 - SDAG: Add a helper to replace and remove a node during ISel

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Wed May 11 15:28:27 PDT 2016


Meador Inge <meadori at gmail.com> writes:
> On Wed, May 11, 2016 at 4:13 PM, Justin Bogner via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
> Author: bogner
>> Date: Wed May 11 16:13:17 2016
>> New Revision: 269236
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=269236&view=rev
>> Log:
>> SDAG: Add a helper to replace and remove a node during ISel
>>
>> It's very common to want to replace a node and then remove it since
>> it's dead, especially as we port backends from the SDNode *Select API
>> to the void Select one. This helper makes this sequence a bit less
>> verbose.
>>
>
> I don't fully understand the context, but ...
>
>
>> -    ReplaceUses(SDValue(Node, 0), SDValue(CNode, 0));
>> -    ReplaceUses(SDValue(Node, 1), SDValue(CNode, 1));
>> +    ReplaceNode(Node, CNode);
>>
>
> ... this replaced sequence and ....
>
>
>> @@ -2152,9 +2150,7 @@ void X86DAGToDAGISel::Select(SDNode *Nod
>>      SDValue Ops[] = {N1, InFlag};
>>      SDNode *CNode = CurDAG->getMachineNode(Opc, dl, VTs, Ops);
>>
>> -    ReplaceUses(SDValue(Node, 0), SDValue(CNode, 0));
>> -    ReplaceUses(SDValue(Node, 1), SDValue(CNode, 1));
>> -    ReplaceUses(SDValue(Node, 2), SDValue(CNode, 2));
>> +    ReplaceUses(Node, CNode);
>>
>
> ... this replaced sequence seem the same, but the latter wasn't
> modified to use `ReplaceNode`.  Should it have been?

Yep, looks like I made a typo here. Fixed in r269245. Thanks for
noticing!


More information about the llvm-commits mailing list