llvm.org GIT mirror llvm / 44303fa
[DAGCombine] Use SelectionDAG::getAnyExtOrTrunc helper. NFCI. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302808 91177308-0d34-0410-b5e6-96231b3b80d8 Simon Pilgrim 3 years ago
1 changed file(s) with 4 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
74357435 N0.getValueType()) ||
74367436 !TLI.isZExtFree(N0.getValueType(), VT))) {
74377437 SDValue X = N0.getOperand(0).getOperand(0);
7438 if (X.getValueType().bitsLT(VT)) {
7439 X = DAG.getNode(ISD::ANY_EXTEND, SDLoc(X), VT, X);
7440 } else if (X.getValueType().bitsGT(VT)) {
7441 X = DAG.getNode(ISD::TRUNCATE, SDLoc(X), VT, X);
7442 }
7438 X = DAG.getAnyExtOrTrunc(X, SDLoc(X), VT);
74437439 APInt Mask = cast(N0.getOperand(1))->getAPIntValue();
74447440 Mask = Mask.zext(VT.getSizeInBits());
74457441 SDLoc DL(N);
76647660 }
76657661
76667662 // fold (aext (truncate x))
7667 if (N0.getOpcode() == ISD::TRUNCATE) {
7668 SDValue TruncOp = N0.getOperand(0);
7669 if (TruncOp.getValueType() == VT)
7670 return TruncOp; // x iff x size == zext size.
7671 if (TruncOp.getValueType().bitsGT(VT))
7672 return DAG.getNode(ISD::TRUNCATE, SDLoc(N), VT, TruncOp);
7673 return DAG.getNode(ISD::ANY_EXTEND, SDLoc(N), VT, TruncOp);
7674 }
7663 if (N0.getOpcode() == ISD::TRUNCATE)
7664 return DAG.getAnyExtOrTrunc(N0.getOperand(0), SDLoc(N), VT);
76757665
76767666 // Fold (aext (and (trunc x), cst)) -> (and x, cst)
76777667 // if the trunc is not free.
76827672 N0.getValueType())) {
76837673 SDLoc DL(N);
76847674 SDValue X = N0.getOperand(0).getOperand(0);
7685 if (X.getValueType().bitsLT(VT)) {
7686 X = DAG.getNode(ISD::ANY_EXTEND, DL, VT, X);
7687 } else if (X.getValueType().bitsGT(VT)) {
7688 X = DAG.getNode(ISD::TRUNCATE, DL, VT, X);
7689 }
7675 X = DAG.getAnyExtOrTrunc(X, DL, VT);
76907676 APInt Mask = cast(N0.getOperand(1))->getAPIntValue();
76917677 Mask = Mask.zext(VT.getSizeInBits());
76927678 return DAG.getNode(ISD::AND, DL, VT,