forked from OSchip/llvm-project
fold (aext (and (trunc x), cst)) -> (and x, cst).
llvm-svn: 30561
This commit is contained in:
parent
fa9f92cf65
commit
082db3f9aa
|
@ -1897,6 +1897,21 @@ SDOperand DAGCombiner::visitANY_EXTEND(SDNode *N) {
|
|||
return DAG.getNode(ISD::TRUNCATE, VT, TruncOp);
|
||||
return DAG.getNode(ISD::ANY_EXTEND, VT, TruncOp);
|
||||
}
|
||||
|
||||
// fold (aext (and (trunc x), cst)) -> (and x, cst).
|
||||
if (N0.getOpcode() == ISD::AND &&
|
||||
N0.getOperand(0).getOpcode() == ISD::TRUNCATE &&
|
||||
N0.getOperand(1).getOpcode() == ISD::Constant) {
|
||||
SDOperand X = N0.getOperand(0).getOperand(0);
|
||||
if (X.getValueType() < VT) {
|
||||
X = DAG.getNode(ISD::ANY_EXTEND, VT, X);
|
||||
} else if (X.getValueType() > VT) {
|
||||
X = DAG.getNode(ISD::TRUNCATE, VT, X);
|
||||
}
|
||||
uint64_t Mask = cast<ConstantSDNode>(N0.getOperand(1))->getValue();
|
||||
return DAG.getNode(ISD::AND, VT, X, DAG.getConstant(Mask, VT));
|
||||
}
|
||||
|
||||
// fold (aext (load x)) -> (aext (truncate (extload x)))
|
||||
if (N0.getOpcode() == ISD::LOAD && N0.hasOneUse() &&
|
||||
(!AfterLegalize||TLI.isOperationLegal(ISD::EXTLOAD, N0.getValueType()))) {
|
||||
|
|
Loading…
Reference in New Issue