forked from OSchip/llvm-project
[DAGCombiner] Use getAnyExtOrTrunc instead of getSExtOrTrunc in the zext(setcc) combine.
We're ANDing with 1 right after which will cause the SIGN_EXTEND to be combined to ANY_EXTEND later. Might as well just start with an ANY_EXTEND. While there replace create the AND using the getZeroExtendInReg helper to remove the need to explicitly create the VecOnes constant.
This commit is contained in:
parent
931c0cd713
commit
97e57f3b24
|
@ -10279,23 +10279,22 @@ SDValue DAGCombiner::visitZERO_EXTEND(SDNode *N) {
|
|||
// that the element size of the sext'd result matches the element size of
|
||||
// the compare operands.
|
||||
SDLoc DL(N);
|
||||
SDValue VecOnes = DAG.getConstant(1, DL, VT);
|
||||
if (VT.getSizeInBits() == N00VT.getSizeInBits()) {
|
||||
// zext(setcc) -> (and (vsetcc), (1, 1, ...) for vectors.
|
||||
// zext(setcc) -> zext_in_reg(vsetcc) for vectors.
|
||||
SDValue VSetCC = DAG.getNode(ISD::SETCC, DL, VT, N0.getOperand(0),
|
||||
N0.getOperand(1), N0.getOperand(2));
|
||||
return DAG.getNode(ISD::AND, DL, VT, VSetCC, VecOnes);
|
||||
return DAG.getZeroExtendInReg(VSetCC, DL, MVT::i1);
|
||||
}
|
||||
|
||||
// If the desired elements are smaller or larger than the source
|
||||
// elements we can use a matching integer vector type and then
|
||||
// truncate/sign extend.
|
||||
// truncate/any extend followed by zext_in_reg.
|
||||
EVT MatchingVectorType = N00VT.changeVectorElementTypeToInteger();
|
||||
SDValue VsetCC =
|
||||
DAG.getNode(ISD::SETCC, DL, MatchingVectorType, N0.getOperand(0),
|
||||
N0.getOperand(1), N0.getOperand(2));
|
||||
return DAG.getNode(ISD::AND, DL, VT, DAG.getSExtOrTrunc(VsetCC, DL, VT),
|
||||
VecOnes);
|
||||
return DAG.getZeroExtendInReg(DAG.getAnyExtOrTrunc(VsetCC, DL, VT),
|
||||
DL, MVT::i1);
|
||||
}
|
||||
|
||||
// zext(setcc x,y,cc) -> select_cc x, y, 1, 0, cc
|
||||
|
|
Loading…
Reference in New Issue