Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
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 4,646 Lines • ▼ Show 20 Lines | SDNode *DAGCombiner::MatchRotate(SDValue LHS, SDValue RHS, const SDLoc &DL) { | ||||
EVT VT = LHS.getValueType(); | EVT VT = LHS.getValueType(); | ||||
if (!TLI.isTypeLegal(VT)) return nullptr; | if (!TLI.isTypeLegal(VT)) return nullptr; | ||||
// The target must have at least one rotate flavor. | // The target must have at least one rotate flavor. | ||||
bool HasROTL = TLI.isOperationLegalOrCustom(ISD::ROTL, VT); | bool HasROTL = TLI.isOperationLegalOrCustom(ISD::ROTL, VT); | ||||
bool HasROTR = TLI.isOperationLegalOrCustom(ISD::ROTR, VT); | bool HasROTR = TLI.isOperationLegalOrCustom(ISD::ROTR, VT); | ||||
if (!HasROTL && !HasROTR) return nullptr; | if (!HasROTL && !HasROTR) return nullptr; | ||||
// Check for truncated rotate. | |||||
if (LHS.getOpcode() == ISD::TRUNCATE && RHS.getOpcode() == ISD::TRUNCATE) { | |||||
assert(LHS.getValueType() == RHS.getValueType()); | |||||
efriedma: Do you need to check that `LHS.getOperand(0).getValueType() == RHS.getOperand(0).getValueType… | |||||
hansAuthorUnsubmitted Not Done ReplyInline ActionsSorry, just hit commit before I saw this. You're right, I need to check that. hans: Sorry, just hit commit before I saw this. You're right, I need to check that. | |||||
hansAuthorUnsubmitted Not Done ReplyInline Actionsr319695 hans: r319695 | |||||
if (SDNode *Rot = MatchRotate(LHS.getOperand(0), RHS.getOperand(0), DL)) { | |||||
return DAG.getNode(ISD::TRUNCATE, SDLoc(LHS), LHS.getValueType(), | |||||
SDValue(Rot, 0)).getNode(); | |||||
} | |||||
} | |||||
// Match "(X shl/srl V1) & V2" where V2 may not be present. | // Match "(X shl/srl V1) & V2" where V2 may not be present. | ||||
SDValue LHSShift; // The shift. | SDValue LHSShift; // The shift. | ||||
SDValue LHSMask; // AND value if any. | SDValue LHSMask; // AND value if any. | ||||
if (!MatchRotateHalf(LHS, LHSShift, LHSMask)) | if (!MatchRotateHalf(LHS, LHSShift, LHSMask)) | ||||
return nullptr; // Not part of a rotate. | return nullptr; // Not part of a rotate. | ||||
SDValue RHSShift; // The shift. | SDValue RHSShift; // The shift. | ||||
SDValue RHSMask; // AND value if any. | SDValue RHSMask; // AND value if any. | ||||
▲ Show 20 Lines • Show All 9,991 Lines • Show Last 20 Lines |
Do you need to check that LHS.getOperand(0).getValueType() == RHS.getOperand(0).getValueType()?