Changeset View
Changeset View
Standalone View
Standalone View
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 3,027 Lines • ▼ Show 20 Lines | SDValue DAGCombiner::visitSUB(SDNode *N) { | ||||
} | } | ||||
// (x - C) - y -> (x - y) - C | // (x - C) - y -> (x - y) - C | ||||
// This is necessary because SUB(X,C) -> ADD(X,-C) doesn't work for vectors. | // This is necessary because SUB(X,C) -> ADD(X,-C) doesn't work for vectors. | ||||
if (N0.hasOneUse() && N0.getOpcode() == ISD::SUB && | if (N0.hasOneUse() && N0.getOpcode() == ISD::SUB && | ||||
isConstantOrConstantVector(N0.getOperand(1), /*NoOpaques=*/true)) { | isConstantOrConstantVector(N0.getOperand(1), /*NoOpaques=*/true)) { | ||||
SDValue Sub = DAG.getNode(ISD::SUB, DL, VT, N0.getOperand(0), N1); | SDValue Sub = DAG.getNode(ISD::SUB, DL, VT, N0.getOperand(0), N1); | ||||
return DAG.getNode(ISD::SUB, DL, VT, Sub, N0.getOperand(1)); | return DAG.getNode(ISD::SUB, DL, VT, Sub, N0.getOperand(1)); | ||||
} | } | ||||
// (C - x) - y -> C - (x + y) | |||||
if (N0.hasOneUse() && N0.getOpcode() == ISD::SUB && | |||||
isConstantOrConstantVector(N0.getOperand(0), /*NoOpaques=*/true)) { | |||||
SDValue Add = DAG.getNode(ISD::ADD, DL, VT, N0.getOperand(1), N1); | |||||
return DAG.getNode(ISD::SUB, DL, VT, N0.getOperand(0), Add); | |||||
} | |||||
// If the target's bool is represented as 0/-1, prefer to make this 'add 0/-1' | // If the target's bool is represented as 0/-1, prefer to make this 'add 0/-1' | ||||
// rather than 'sub 0/1' (the sext should get folded). | // rather than 'sub 0/1' (the sext should get folded). | ||||
// sub X, (zext i1 Y) --> add X, (sext i1 Y) | // sub X, (zext i1 Y) --> add X, (sext i1 Y) | ||||
if (N1.getOpcode() == ISD::ZERO_EXTEND && | if (N1.getOpcode() == ISD::ZERO_EXTEND && | ||||
N1.getOperand(0).getScalarValueSizeInBits() == 1 && | N1.getOperand(0).getScalarValueSizeInBits() == 1 && | ||||
TLI.getBooleanContents(VT) == | TLI.getBooleanContents(VT) == | ||||
TargetLowering::ZeroOrNegativeOneBooleanContent) { | TargetLowering::ZeroOrNegativeOneBooleanContent) { | ||||
▲ Show 20 Lines • Show All 17,512 Lines • Show Last 20 Lines |