@@ -5343,12 +5343,11 @@ void X86DAGToDAGISel::Select(SDNode *Node) {
5343
5343
// We have to do this manually because tblgen will put the eflags copy in
5344
5344
// the wrong place if we use an extract_subreg in the pattern.
5345
5345
MVT VT = Node->getSimpleValueType (0 );
5346
- SDValue Chain = CurDAG->getEntryNode ();
5347
5346
5348
5347
// Copy flags to the EFLAGS register and glue it to next node.
5349
- SDValue EFLAGS = CurDAG-> getCopyToReg (Chain, dl, X86::EFLAGS,
5350
- Node-> getOperand ( 1 ), SDValue ());
5351
- Chain = EFLAGS ;
5348
+ SDValue EFLAGS =
5349
+ CurDAG-> getCopyToReg (CurDAG-> getEntryNode ( ), dl, X86::EFLAGS,
5350
+ Node-> getOperand ( 1 ), SDValue ()) ;
5352
5351
5353
5352
// Create a 64-bit instruction if the result is 64-bits otherwise use the
5354
5353
// 32-bit version.
@@ -5367,6 +5366,56 @@ void X86DAGToDAGISel::Select(SDNode *Node) {
5367
5366
CurDAG->RemoveDeadNode (Node);
5368
5367
return ;
5369
5368
}
5369
+ case X86ISD::SBB: {
5370
+ if (isNullConstant (Node->getOperand (0 )) &&
5371
+ isNullConstant (Node->getOperand (1 ))) {
5372
+ MVT VT = Node->getSimpleValueType (0 );
5373
+
5374
+ // Create zero.
5375
+ SDVTList VTs = CurDAG->getVTList (MVT::i32 , MVT::i32 );
5376
+ SDValue Zero =
5377
+ SDValue (CurDAG->getMachineNode (X86::MOV32r0, dl, VTs, None), 0 );
5378
+ if (VT == MVT::i64 ) {
5379
+ Zero = SDValue (
5380
+ CurDAG->getMachineNode (
5381
+ TargetOpcode::SUBREG_TO_REG, dl, MVT::i64 ,
5382
+ CurDAG->getTargetConstant (0 , dl, MVT::i64 ), Zero,
5383
+ CurDAG->getTargetConstant (X86::sub_32bit, dl, MVT::i32 )),
5384
+ 0 );
5385
+ }
5386
+
5387
+ // Copy flags to the EFLAGS register and glue it to next node.
5388
+ SDValue EFLAGS =
5389
+ CurDAG->getCopyToReg (CurDAG->getEntryNode (), dl, X86::EFLAGS,
5390
+ Node->getOperand (2 ), SDValue ());
5391
+
5392
+ // Create a 64-bit instruction if the result is 64-bits otherwise use the
5393
+ // 32-bit version.
5394
+ unsigned Opc = VT == MVT::i64 ? X86::SBB64rr : X86::SBB32rr;
5395
+ MVT SBBVT = VT == MVT::i64 ? MVT::i64 : MVT::i32 ;
5396
+ VTs = CurDAG->getVTList (SBBVT, MVT::i32 );
5397
+ SDValue Result =
5398
+ SDValue (CurDAG->getMachineNode (Opc, dl, VTs, {Zero, Zero, EFLAGS,
5399
+ EFLAGS.getValue (1 )}),
5400
+ 0 );
5401
+
5402
+ // Replace the flag use.
5403
+ ReplaceUses (SDValue (Node, 1 ), Result.getValue (1 ));
5404
+
5405
+ // Replace the result use.
5406
+ if (!SDValue (Node, 0 ).use_empty ()) {
5407
+ // For less than 32-bits we need to extract from the 32-bit node.
5408
+ if (VT == MVT::i8 || VT == MVT::i16 ) {
5409
+ int SubIndex = VT == MVT::i16 ? X86::sub_16bit : X86::sub_8bit;
5410
+ Result = CurDAG->getTargetExtractSubreg (SubIndex, dl, VT, Result);
5411
+ }
5412
+ ReplaceUses (SDValue (Node, 0 ), Result);
5413
+ }
5414
+
5415
+ CurDAG->RemoveDeadNode (Node);
5416
+ return ;
5417
+ }
5418
+ }
5370
5419
}
5371
5420
5372
5421
SelectCode (Node);
0 commit comments