- if (NeedTruncation) {
- SDValue WideVal = Op->getOperand(0);
- EVT VT = Op.getValueType();
- EVT WideVT = WideVal.getValueType();
- unsigned ConvertedOp = 0;
-
- // Use a target machine opcode to prevent further DAGCombine
- // optimizations that may separate the arithmetic operations from the
- // setcc node.
- switch (WideVal.getOpcode()) {
- default: break;
- case ISD::ADD: ConvertedOp = X86ISD::ADD; break;
- case ISD::SUB: ConvertedOp = X86ISD::SUB; break;
- case ISD::AND: ConvertedOp = X86ISD::AND; break;
- case ISD::OR: ConvertedOp = X86ISD::OR; break;
- case ISD::XOR: ConvertedOp = X86ISD::XOR; break;
- }
-
- if (ConvertedOp && WideVal.hasOneUse()) {
- const TargetLowering &TLI = DAG.getTargetLoweringInfo();
- if (TLI.isOperationLegal(WideVal.getOpcode(), WideVT)) {
- SDValue V0 = DAG.getNode(ISD::TRUNCATE, dl, VT, WideVal.getOperand(0));
- SDValue V1 = DAG.getNode(ISD::TRUNCATE, dl, VT, WideVal.getOperand(1));
- Op = DAG.getNode(ConvertedOp, dl, VT, V0, V1);
- }
- }
- }
-