[PATCH] D38942: [DAG] Promote ADDCARRY / SUBCARRY
Roger Ferrer Ibanez via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 7 11:06:57 PST 2017
rogfer01 added a comment.
The generic combiner `DAGCombiner::visitTRUNCATE` does this
// (trunc adde(X, Y, Carry)) -> (adde trunc(X), trunc(Y), Carry)
// (trunc addcarry(X, Y, Carry)) -> (addcarry trunc(X), trunc(Y), Carry)
// When the adde's carry is not used.
if ((N0.getOpcode() == ISD::ADDE || N0.getOpcode() == ISD::ADDCARRY) &&
N0.hasOneUse() && !N0.getNode()->hasAnyUseOfValue(1) &&
(!LegalOperations || TLI.isOperationLegal(N0.getOpcode(), VT))) {
SDLoc SL(N);
auto X = DAG.getNode(ISD::TRUNCATE, SL, VT, N0.getOperand(0));
auto Y = DAG.getNode(ISD::TRUNCATE, SL, VT, N0.getOperand(1));
auto VTs = DAG.getVTList(VT, N0->getValueType(1));
return DAG.getNode(N0.getOpcode(), SL, VTs, X, Y, N0.getOperand(2));
}
Here `N0` is `t22: i32,i1 = addcarry t12, Constant:i32<0>, t7:1` but `VT` is `i16` and it is used in the `VTs` of the final `getNode`, but this happens before legalize types, this is, inside this
// Run the DAG combiner in pre-legalize mode.
{
NamedRegionTimer T("combine1", "DAG Combining 1", GroupName,
GroupDescription, TimePassesIsEnabled);
CurDAG->Combine(BeforeLegalizeTypes, AA, OptLevel);
}
so I think it is valid to create this node and what we are missing is a promotion for it so it finally becomes legal.
Does this make sense @efriedma ?
https://reviews.llvm.org/D38942
More information about the llvm-commits
mailing list