@@ -446,6 +446,38 @@ namespace {
446
446
return getI8Imm (InsertIdx ? 0x02 : 0x30 , DL);
447
447
}
448
448
449
+ SDValue getSBBZero (SDNode *N) {
450
+ SDLoc dl (N);
451
+ MVT VT = N->getSimpleValueType (0 );
452
+
453
+ // Create zero.
454
+ SDVTList VTs = CurDAG->getVTList (MVT::i32 , MVT::i32 );
455
+ SDValue Zero =
456
+ SDValue (CurDAG->getMachineNode (X86::MOV32r0, dl, VTs, None), 0 );
457
+ if (VT == MVT::i64 ) {
458
+ Zero = SDValue (
459
+ CurDAG->getMachineNode (
460
+ TargetOpcode::SUBREG_TO_REG, dl, MVT::i64 ,
461
+ CurDAG->getTargetConstant (0 , dl, MVT::i64 ), Zero,
462
+ CurDAG->getTargetConstant (X86::sub_32bit, dl, MVT::i32 )),
463
+ 0 );
464
+ }
465
+
466
+ // Copy flags to the EFLAGS register and glue it to next node.
467
+ SDValue EFLAGS = CurDAG->getCopyToReg (
468
+ CurDAG->getEntryNode (), dl, X86::EFLAGS, N->getOperand (2 ), SDValue ());
469
+
470
+ // Create a 64-bit instruction if the result is 64-bits otherwise use the
471
+ // 32-bit version.
472
+ unsigned Opc = VT == MVT::i64 ? X86::SBB64rr : X86::SBB32rr;
473
+ MVT SBBVT = VT == MVT::i64 ? MVT::i64 : MVT::i32 ;
474
+ VTs = CurDAG->getVTList (SBBVT, MVT::i32 );
475
+ return SDValue (
476
+ CurDAG->getMachineNode (Opc, dl, VTs,
477
+ {Zero, Zero, EFLAGS, EFLAGS.getValue (1 )}),
478
+ 0 );
479
+ }
480
+
449
481
// Helper to detect unneeded and instructions on shift amounts. Called
450
482
// from PatFrags in tablegen.
451
483
bool isUnneededShiftMask (SDNode *N, unsigned Width) const {
@@ -5798,42 +5830,15 @@ void X86DAGToDAGISel::Select(SDNode *Node) {
5798
5830
case X86ISD::SBB: {
5799
5831
if (isNullConstant (Node->getOperand (0 )) &&
5800
5832
isNullConstant (Node->getOperand (1 ))) {
5801
- MVT VT = Node->getSimpleValueType (0 );
5802
-
5803
- // Create zero.
5804
- SDVTList VTs = CurDAG->getVTList (MVT::i32 , MVT::i32 );
5805
- SDValue Zero =
5806
- SDValue (CurDAG->getMachineNode (X86::MOV32r0, dl, VTs, None), 0 );
5807
- if (VT == MVT::i64 ) {
5808
- Zero = SDValue (
5809
- CurDAG->getMachineNode (
5810
- TargetOpcode::SUBREG_TO_REG, dl, MVT::i64 ,
5811
- CurDAG->getTargetConstant (0 , dl, MVT::i64 ), Zero,
5812
- CurDAG->getTargetConstant (X86::sub_32bit, dl, MVT::i32 )),
5813
- 0 );
5814
- }
5815
-
5816
- // Copy flags to the EFLAGS register and glue it to next node.
5817
- SDValue EFLAGS =
5818
- CurDAG->getCopyToReg (CurDAG->getEntryNode (), dl, X86::EFLAGS,
5819
- Node->getOperand (2 ), SDValue ());
5820
-
5821
- // Create a 64-bit instruction if the result is 64-bits otherwise use the
5822
- // 32-bit version.
5823
- unsigned Opc = VT == MVT::i64 ? X86::SBB64rr : X86::SBB32rr;
5824
- MVT SBBVT = VT == MVT::i64 ? MVT::i64 : MVT::i32 ;
5825
- VTs = CurDAG->getVTList (SBBVT, MVT::i32 );
5826
- SDValue Result =
5827
- SDValue (CurDAG->getMachineNode (Opc, dl, VTs, {Zero, Zero, EFLAGS,
5828
- EFLAGS.getValue (1 )}),
5829
- 0 );
5833
+ SDValue Result = getSBBZero (Node);
5830
5834
5831
5835
// Replace the flag use.
5832
5836
ReplaceUses (SDValue (Node, 1 ), Result.getValue (1 ));
5833
5837
5834
5838
// Replace the result use.
5835
5839
if (!SDValue (Node, 0 ).use_empty ()) {
5836
5840
// For less than 32-bits we need to extract from the 32-bit node.
5841
+ MVT VT = Node->getSimpleValueType (0 );
5837
5842
if (VT == MVT::i8 || VT == MVT::i16 ) {
5838
5843
int SubIndex = VT == MVT::i16 ? X86::sub_16bit : X86::sub_8bit;
5839
5844
Result = CurDAG->getTargetExtractSubreg (SubIndex, dl, VT, Result);
0 commit comments