[llvm-commits] [llvm] r164835 - /llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
Manman Ren
mren at apple.com
Fri Sep 28 12:47:59 PDT 2012
On Sep 28, 2012, at 12:38 PM, Sean Silva <silvas at purdue.edu> wrote:
> Can you factor this into a separate function instead of copypasting
> it? It would also tie together these 4 pieces of code as doing
> logically the same thing and isolate the ways in which the 4 code
> sequences differ.
This function will only have two lines:
getMachineNode and ReplaceUses
and we need to pass in a lot of arguments.
Another option is to handle the common section at end, but we need to do "else if" for the 3 cases.
Thanks,
Manman
>
> --Sean Silva
>
> On Fri, Sep 28, 2012 at 2:53 PM, Manman Ren <mren at apple.com> wrote:
>> Author: mren
>> Date: Fri Sep 28 13:53:24 2012
>> New Revision: 164835
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=164835&view=rev
>> Log:
>> X86: when replacing SUB with TEST in ISelDAGToDAG, only replace uses of the
>> second output of SUB with first output of TEST.
>>
>> PR13966
>>
>> Modified:
>> llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
>>
>> Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=164835&r1=164834&r2=164835&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original)
>> +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Fri Sep 28 13:53:24 2012
>> @@ -2525,7 +2525,13 @@
>> MVT::i8, Reg);
>>
>> // Emit a testb.
>> - return CurDAG->getMachineNode(X86::TEST8ri, dl, MVT::i32, Subreg, Imm);
>> + SDNode *NewNode = CurDAG->getMachineNode(X86::TEST8ri, dl, MVT::i32,
>> + Subreg, Imm);
>> + // Replace SUB|CMP with TEST, since SUB has two outputs while TEST has
>> + // one, do not call ReplaceAllUsesWith.
>> + ReplaceUses(SDValue(Node, (Opcode == X86ISD::SUB ? 1 : 0)),
>> + SDValue(NewNode, 0));
>> + return NULL;
>> }
>>
>> // For example, "testl %eax, $2048" to "testb %ah, $8".
>> @@ -2556,8 +2562,13 @@
>> // Emit a testb. The EXTRACT_SUBREG becomes a COPY that can only
>> // target GR8_NOREX registers, so make sure the register class is
>> // forced.
>> - return CurDAG->getMachineNode(X86::TEST8ri_NOREX, dl, MVT::i32,
>> - Subreg, ShiftedImm);
>> + SDNode *NewNode = CurDAG->getMachineNode(X86::TEST8ri_NOREX, dl,
>> + MVT::i32, Subreg, ShiftedImm);
>> + // Replace SUB|CMP with TEST, since SUB has two outputs while TEST has
>> + // one, do not call ReplaceAllUsesWith.
>> + ReplaceUses(SDValue(Node, (Opcode == X86ISD::SUB ? 1 : 0)),
>> + SDValue(NewNode, 0));
>> + return NULL;
>> }
>>
>> // For example, "testl %eax, $32776" to "testw %ax, $32776".
>> @@ -2573,7 +2584,13 @@
>> MVT::i16, Reg);
>>
>> // Emit a testw.
>> - return CurDAG->getMachineNode(X86::TEST16ri, dl, MVT::i32, Subreg, Imm);
>> + SDNode *NewNode = CurDAG->getMachineNode(X86::TEST16ri, dl, MVT::i32,
>> + Subreg, Imm);
>> + // Replace SUB|CMP with TEST, since SUB has two outputs while TEST has
>> + // one, do not call ReplaceAllUsesWith.
>> + ReplaceUses(SDValue(Node, (Opcode == X86ISD::SUB ? 1 : 0)),
>> + SDValue(NewNode, 0));
>> + return NULL;
>> }
>>
>> // For example, "testq %rax, $268468232" to "testl %eax, $268468232".
>> @@ -2589,7 +2606,13 @@
>> MVT::i32, Reg);
>>
>> // Emit a testl.
>> - return CurDAG->getMachineNode(X86::TEST32ri, dl, MVT::i32, Subreg, Imm);
>> + SDNode *NewNode = CurDAG->getMachineNode(X86::TEST32ri, dl, MVT::i32,
>> + Subreg, Imm);
>> + // Replace SUB|CMP with TEST, since SUB has two outputs while TEST has
>> + // one, do not call ReplaceAllUsesWith.
>> + ReplaceUses(SDValue(Node, (Opcode == X86ISD::SUB ? 1 : 0)),
>> + SDValue(NewNode, 0));
>> + return NULL;
>> }
>> }
>> break;
>>
>>
>> _______________________________________________
>> 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