summaryrefslogtreecommitdiff
path: root/lib/Target/Alpha
diff options
context:
space:
mode:
authorAndrew Lenharth <andrewl@lenharth.org>2006-04-03 04:19:17 +0000
committerAndrew Lenharth <andrewl@lenharth.org>2006-04-03 04:19:17 +0000
commitf87e7931fd46f954054cd2b95ce341671ae4119d (patch)
tree36de429451f198ae223a1dceac4ccce2c3764542 /lib/Target/Alpha
parent87e021de4f83bc8f1890c392de3858f6176461ca (diff)
downloadllvm-f87e7931fd46f954054cd2b95ce341671ae4119d.tar.gz
llvm-f87e7931fd46f954054cd2b95ce341671ae4119d.tar.bz2
llvm-f87e7931fd46f954054cd2b95ce341671ae4119d.tar.xz
support x * (c1 + c2) where c1 and c2 are pow2s. special case for c2 == 4
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27370 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Alpha')
-rw-r--r--lib/Target/Alpha/AlphaISelDAGToDAG.cpp2
-rw-r--r--lib/Target/Alpha/AlphaInstrInfo.td40
2 files changed, 32 insertions, 10 deletions
diff --git a/lib/Target/Alpha/AlphaISelDAGToDAG.cpp b/lib/Target/Alpha/AlphaISelDAGToDAG.cpp
index 03e6246c01..e16411f5e3 100644
--- a/lib/Target/Alpha/AlphaISelDAGToDAG.cpp
+++ b/lib/Target/Alpha/AlphaISelDAGToDAG.cpp
@@ -77,7 +77,7 @@ namespace {
uint64_t complow = 1 << (63 - at);
uint64_t comphigh = 1 << (64 - at);
//std::cerr << x << ":" << complow << ":" << comphigh << "\n";
- if (abs(complow - x) < abs(comphigh - x))
+ if (abs(complow - x) <= abs(comphigh - x))
return complow;
else
return comphigh;
diff --git a/lib/Target/Alpha/AlphaInstrInfo.td b/lib/Target/Alpha/AlphaInstrInfo.td
index 1422466e3f..5fa770a0c7 100644
--- a/lib/Target/Alpha/AlphaInstrInfo.td
+++ b/lib/Target/Alpha/AlphaInstrInfo.td
@@ -60,6 +60,10 @@ def iZAPX : SDNodeXForm<imm, [{ // get imm to ZAPi
def nearP2X : SDNodeXForm<imm, [{
return getI64Imm(Log2_64(getNearPower2((uint64_t)N->getValue())));
}]>;
+def nearP2RemX : SDNodeXForm<imm, [{
+ uint64_t x = abs(N->getValue() - getNearPower2((uint64_t)N->getValue()));
+ return getI64Imm(Log2_64(x));
+}]>;
def immUExt8 : PatLeaf<(imm), [{ //imm fits in 8 bit zero extended field
return (uint64_t)N->getValue() == (uint8_t)N->getValue();
@@ -84,26 +88,39 @@ def immFPZ : PatLeaf<(fpimm), [{ //the only fpconstant nodes are +/- 0.0
return true;
}]>;
def immRem1 : PatLeaf<(imm), [{
- return (int64_t)getNearPower2((uint64_t)N->getValue()) - (int64_t)N->getValue() == -1;
+ return N->getValue() - getNearPower2((uint64_t)N->getValue()) == 1;
}]>;
def immRem3 : PatLeaf<(imm), [{
- return (int64_t)getNearPower2((uint64_t)N->getValue()) - (int64_t)N->getValue() == -3;
+ return N->getValue() - getNearPower2((uint64_t)N->getValue()) == 3;
+}]>;
+def immRem4 : PatLeaf<(imm), [{
+ return N->getValue() - getNearPower2((uint64_t)N->getValue()) == 4;
}]>;
def immRem5 : PatLeaf<(imm), [{
- return (int64_t)getNearPower2((uint64_t)N->getValue()) - (int64_t)N->getValue() == -5;
+ return N->getValue() - getNearPower2((uint64_t)N->getValue()) == 5;
}]>;
def immRem1n : PatLeaf<(imm), [{
- return (int64_t)getNearPower2((uint64_t)N->getValue()) - N->getValue() == 1;
+ return getNearPower2((uint64_t)N->getValue()) - N->getValue() == 1;
}]>;
def immRem3n : PatLeaf<(imm), [{
- return (int64_t)getNearPower2((uint64_t)N->getValue()) - N->getValue() == 3;
+ return getNearPower2((uint64_t)N->getValue()) - N->getValue() == 3;
+}]>;
+def immRem4n : PatLeaf<(imm), [{
+ return getNearPower2((uint64_t)N->getValue()) - N->getValue() == 4;
}]>;
def immRem5n : PatLeaf<(imm), [{
- return (int64_t)getNearPower2((uint64_t)N->getValue()) - N->getValue() == 5;
+ return getNearPower2((uint64_t)N->getValue()) - N->getValue() == 5;
+}]>;
+def immRemP2n : PatLeaf<(imm), [{
+ return isPowerOf2_64(getNearPower2((uint64_t)N->getValue()) - N->getValue());
+}]>;
+def immRemP2 : PatLeaf<(imm), [{
+ return isPowerOf2_64(N->getValue() - getNearPower2((uint64_t)N->getValue()));
}]>;
def immUExt8ME : PatLeaf<(imm), [{ //use this imm for mulqi
- int64_t d = (int64_t)getNearPower2((uint64_t)N->getValue()) - N->getValue();
- switch (abs(d)) {
+ int64_t d = abs((int64_t)N->getValue() - (int64_t)getNearPower2((uint64_t)N->getValue()));
+ if (isPowerOf2_64(d)) return false;
+ switch (d) {
case 1: case 3: case 5: return false;
default: return (uint64_t)N->getValue() == (uint8_t)N->getValue();
};
@@ -915,6 +932,10 @@ def : Pat<(mul GPRC:$RA, immRem3:$imm),
(ADDQ (SL GPRC:$RA, (nearP2X immRem3:$imm)), (S4SUBQ GPRC:$RA, GPRC:$RA))>;
def : Pat<(mul GPRC:$RA, immRem5:$imm),
(ADDQ (SL GPRC:$RA, (nearP2X immRem5:$imm)), (S4ADDQ GPRC:$RA, GPRC:$RA))>;
+def : Pat<(mul GPRC:$RA, immRem4:$imm),
+ (S4ADDQ GPRC:$RA, (SL GPRC:$RA, (nearP2X immRem4:$imm)))>;
+def : Pat<(mul GPRC:$RA, immRemP2:$imm),
+ (ADDQ (SL GPRC:$RA, (nearP2X immRemP2:$imm)), (SLi GPRC:$RA, (nearP2RemX immRemP2:$imm)))>;
def : Pat<(mul GPRC:$RA, immRem1n:$imm),
(SUBQ (SL GPRC:$RA, (nearP2X immRem1n:$imm)), GPRC:$RA)>;
@@ -922,4 +943,5 @@ def : Pat<(mul GPRC:$RA, immRem3n:$imm),
(SUBQ (SL GPRC:$RA, (nearP2X immRem3n:$imm)), (S4SUBQ GPRC:$RA, GPRC:$RA))>;
def : Pat<(mul GPRC:$RA, immRem5n:$imm),
(SUBQ (SL GPRC:$RA, (nearP2X immRem5n:$imm)), (S4ADDQ GPRC:$RA, GPRC:$RA))>;
-
+def : Pat<(mul GPRC:$RA, immRemP2n:$imm),
+ (SUBQ (SL GPRC:$RA, (nearP2X immRemP2n:$imm)), (SLi GPRC:$RA, (nearP2RemX immRemP2n:$imm)))>;