Add Constant Hoisting Pass

Retry commit r200022 with a fix for the build bot errors. Constant expressions
have (unlike instructions) module scope use lists and therefore may have users
in different functions. The fix is to simply ignore these out-of-function uses.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200034 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Juergen Ributzka
2014-01-24 20:18:00 +00:00
parent 86720f7c65
commit 96172cb4a4
20 changed files with 722 additions and 40 deletions

View File

@@ -3212,11 +3212,14 @@ SDValue DAGCombiner::visitOR(SDNode *N) {
if (N1C && N0.getOpcode() == ISD::AND && N0.getNode()->hasOneUse() &&
isa<ConstantSDNode>(N0.getOperand(1))) {
ConstantSDNode *C1 = cast<ConstantSDNode>(N0.getOperand(1));
if ((C1->getAPIntValue() & N1C->getAPIntValue()) != 0)
if ((C1->getAPIntValue() & N1C->getAPIntValue()) != 0) {
SDValue COR = DAG.FoldConstantArithmetic(ISD::OR, VT, N1C, C1);
if (!COR.getNode())
return SDValue();
return DAG.getNode(ISD::AND, SDLoc(N), VT,
DAG.getNode(ISD::OR, SDLoc(N0), VT,
N0.getOperand(0), N1),
DAG.FoldConstantArithmetic(ISD::OR, VT, N1C, C1));
N0.getOperand(0), N1), COR);
}
}
// fold (or (setcc x), (setcc y)) -> (setcc (or x, y))
if (isSetCCEquivalent(N0, LL, LR, CC0) && isSetCCEquivalent(N1, RL, RR, CC1)){