Details
Details
- Reviewers
• tstellarAMD arsenm resistor
Diff Detail
Diff Detail
Event Timeline
Comment Actions
LGTM. We actually do this out of tree in our backend for ADD, SUB, MUL, SHL (since we'd rather truncate inputs than do a larger op and truncate that), so it seems more than reasonable to me.
Comment Actions
Some might be, as this code is fairly old. Here’s an extremely blind copy paste of our code:
// Truncate from an add should just reduce the size of the add and // truncate the sources. This is always a good idea for us as truncates // are free while large adds/subs/muls are not. switch (Source->getOpcode()) { case ISD::ADD: case ISD::SUB: case ISD::MUL: case ISD::SHL: { if (!AllUsersAreTruncate(Source)) break; auto VT = N->getValueType(0); SDValue Trunc0 = DCI.DAG.getNode(ISD::TRUNCATE, dl, VT, Source->getOperand(0)); SDValue Trunc1 = DCI.DAG.getNode(ISD::TRUNCATE, dl, VT, Source->getOperand(1)); DCI.AddToWorklist(Trunc0.getNode()); DCI.AddToWorklist(Trunc1.getNode()); return DCI.DAG.getNode(Source->getOpcode(), dl, VT, Trunc0, Trunc1); } }
—escha