bool negSrc1 = (srcElem1 < 0);
bool negSrc2 = (srcElem2 < 0);
if ((negDest != negSrc1) && (negSrc1 == negSrc2)) {
- destElem = (Element)1 << (sizeof(Element) * 8 - 1);
if (negDest)
- destElem -= 1;
+ /* If (>=0) plus (>=0) yields (<0), saturate to +. */
+ destElem = std::numeric_limits<Element>::max();
+ else
+ /* If (<0) plus (<0) yields (>=0), saturate to -. */
+ destElem = std::numeric_limits<Element>::min();
fpscr.qc = 1;
}
FpscrQc = fpscr;
bool negSrc1 = (srcElem1 < 0);
bool posSrc2 = (srcElem2 >= 0);
if ((negDest != negSrc1) && (negSrc1 == posSrc2)) {
- destElem = (Element)1 << (sizeof(Element) * 8 - 1);
if (negDest)
- destElem -= 1;
+ /* If (>=0) minus (<0) yields (<0), saturate to +. */
+ destElem = std::numeric_limits<Element>::max();
+ else
+ /* If (<0) minus (>=0) yields (>=0), saturate to -. */
+ destElem = std::numeric_limits<Element>::min();
fpscr.qc = 1;
}
FpscrQc = fpscr;
vqdmlalCode = '''
FPSCR fpscr = (FPSCR) FpscrQc;
BigElement midElem = (2 * (int64_t)srcElem1 * (int64_t)srcElem2);
- Element maxNeg = (Element)1 << (sizeof(Element) * 8 - 1);
+ Element maxNeg = std::numeric_limits<Element>::min();
Element halfNeg = maxNeg / 2;
if ((srcElem1 == maxNeg && srcElem2 == maxNeg) ||
(srcElem1 == halfNeg && srcElem2 == maxNeg) ||
vqdmlslCode = '''
FPSCR fpscr = (FPSCR) FpscrQc;
BigElement midElem = (2 * (int64_t)srcElem1 * (int64_t)srcElem2);
- Element maxNeg = (Element)1 << (sizeof(Element) * 8 - 1);
+ Element maxNeg = std::numeric_limits<Element>::min();
Element halfNeg = maxNeg / 2;
if ((srcElem1 == maxNeg && srcElem2 == maxNeg) ||
(srcElem1 == halfNeg && srcElem2 == maxNeg) ||
FPSCR fpscr = (FPSCR) FpscrQc;
destElem = (2 * (int64_t)srcElem1 * (int64_t)srcElem2);
if (srcElem1 == srcElem2 &&
- srcElem1 == (Element)((Element)1 <<
- (Element)(sizeof(Element) * 8 - 1))) {
+ srcElem1 == (Element)(std::numeric_limits<Element>::min())) {
destElem = ~((BigElement)srcElem1 << (sizeof(Element) * 8));
fpscr.qc = 1;
}
destElem = (2 * (int64_t)srcElem1 * (int64_t)srcElem2) >>
(sizeof(Element) * 8);
if (srcElem1 == srcElem2 &&
- srcElem1 == (Element)((Element)1 <<
- (sizeof(Element) * 8 - 1))) {
+ srcElem1 == (Element)(std::numeric_limits<Element>::min())) {
destElem = ~srcElem1;
fpscr.qc = 1;
}
destElem = (2 * (int64_t)srcElem1 * (int64_t)srcElem2 +
((int64_t)1 << (sizeof(Element) * 8 - 1))) >>
(sizeof(Element) * 8);
- Element maxNeg = (Element)1 << (sizeof(Element) * 8 - 1);
+ Element maxNeg = std::numeric_limits<Element>::min();
Element halfNeg = maxNeg / 2;
if ((srcElem1 == maxNeg && srcElem2 == maxNeg) ||
(srcElem1 == halfNeg && srcElem2 == maxNeg) ||
if (destElem < 0) {
destElem = mask(sizeof(Element) * 8 - 1);
} else {
- destElem = (Element)1 << (sizeof(Element) * 8 - 1);
+ destElem = std::numeric_limits<Element>::min();
}
fpscr.qc = 1;
}
FPSCR fpscr = (FPSCR) FpscrQc;
if (imm >= sizeof(Element) * 8) {
if (srcElem1 != 0) {
- destElem = (Element)1 << (sizeof(Element) * 8 - 1);
+ destElem = std::numeric_limits<Element>::min();
if (srcElem1 > 0)
destElem = ~destElem;
fpscr.qc = 1;
sizeof(Element) * 8 - 1,
sizeof(Element) * 8 - 1 - imm);
if (topBits != 0 && topBits != mask(imm + 1)) {
- destElem = (Element)1 << (sizeof(Element) * 8 - 1);
+ destElem = std::numeric_limits<Element>::min();
if (srcElem1 > 0)
destElem = ~destElem;
fpscr.qc = 1;
vqabsCode = '''
FPSCR fpscr = (FPSCR) FpscrQc;
- if (srcElem1 == (Element)((Element)1 << (sizeof(Element) * 8 - 1))) {
+ if (srcElem1 == (Element)(std::numeric_limits<Element>::min())) {
fpscr.qc = 1;
destElem = ~srcElem1;
} else if (srcElem1 < 0) {
vqnegCode = '''
FPSCR fpscr = (FPSCR) FpscrQc;
- if (srcElem1 == (Element)((Element)1 << (sizeof(Element) * 8 - 1))) {
+ if (srcElem1 == (Element)(std::numeric_limits<Element>::min())) {
fpscr.qc = 1;
destElem = ~srcElem1;
} else {
# SQABS
sqabsCode = '''
FPSCR fpscr = (FPSCR) FpscrQc;
- if (srcElem1 == (Element)((Element)1 << (sizeof(Element) * 8 - 1))) {
+ if (srcElem1 == (Element)(std::numeric_limits<Element>::min())) {
fpscr.qc = 1;
destElem = ~srcElem1;
} else if (srcElem1 < 0) {
bool negSrc1 = (srcElem1 < 0);
bool negSrc2 = (srcElem2 < 0);
if ((negDest != negSrc1) && (negSrc1 == negSrc2)) {
- destElem = (Element)1 << (sizeof(Element) * 8 - 1);
+ destElem = std::numeric_limits<Element>::min();
if (negDest)
destElem -= 1;
fpscr.qc = 1;
qdmlalCode = '''
FPSCR fpscr = (FPSCR) FpscrQc;
BigElement midElem = (2 * (int64_t)srcElem1 * (int64_t)srcElem2);
- Element maxNeg = (Element)1 << (sizeof(Element) * 8 - 1);
+ Element maxNeg = std::numeric_limits<Element>::min();
Element halfNeg = maxNeg / 2;
if ((srcElem1 == maxNeg && srcElem2 == maxNeg) ||
(srcElem1 == halfNeg && srcElem2 == maxNeg) ||
qdmlslCode = '''
FPSCR fpscr = (FPSCR) FpscrQc;
BigElement midElem = (2 * (int64_t)srcElem1 * (int64_t)srcElem2);
- Element maxNeg = (Element)1 << (sizeof(Element) * 8 - 1);
+ Element maxNeg = std::numeric_limits<Element>::min();
Element halfNeg = maxNeg / 2;
if ((srcElem1 == maxNeg && srcElem2 == maxNeg) ||
(srcElem1 == halfNeg && srcElem2 == maxNeg) ||
# SQNEG
sqnegCode = '''
FPSCR fpscr = (FPSCR) FpscrQc;
- if (srcElem1 == (Element)((Element)1 << (sizeof(Element) * 8 - 1))) {
+ if (srcElem1 == (Element)(std::numeric_limits<Element>::min())) {
fpscr.qc = 1;
destElem = ~srcElem1;
} else {
destElem = (2 * (int64_t)srcElem1 * (int64_t)srcElem2 +
((int64_t)1 << (sizeof(Element) * 8 - 1))) >>
(sizeof(Element) * 8);
- Element maxNeg = (Element)1 << (sizeof(Element) * 8 - 1);
+ Element maxNeg = std::numeric_limits<Element>::min();
Element halfNeg = maxNeg / 2;
if ((srcElem1 == maxNeg && srcElem2 == maxNeg) ||
(srcElem1 == halfNeg && srcElem2 == maxNeg) ||
if (destElem < 0) {
destElem = mask(sizeof(Element) * 8 - 1);
} else {
- destElem = (Element)1 << (sizeof(Element) * 8 - 1);
+ destElem = std::numeric_limits<Element>::min();
}
fpscr.qc = 1;
}
FPSCR fpscr = (FPSCR) FpscrQc;
if (imm >= sizeof(Element) * 8) {
if (srcElem1 != 0) {
- destElem = (Element)1 << (sizeof(Element) * 8 - 1);
+ destElem = std::numeric_limits<Element>::min();
if (srcElem1 > 0)
destElem = ~destElem;
fpscr.qc = 1;
sizeof(Element) * 8 - 1,
sizeof(Element) * 8 - 1 - imm);
if (topBits != 0 && topBits != mask(imm + 1)) {
- destElem = (Element)1 << (sizeof(Element) * 8 - 1);
+ destElem = std::numeric_limits<Element>::min();
if (srcElem1 > 0)
destElem = ~destElem;
fpscr.qc = 1;
bool negSrc1 = (srcElem1 < 0);
bool posSrc2 = (srcElem2 >= 0);
if ((negDest != negSrc1) && (negSrc1 == posSrc2)) {
- destElem = (Element)1 << (sizeof(Element) * 8 - 1);
+ destElem = std::numeric_limits<Element>::min();
if (negDest)
destElem -= 1;
fpscr.qc = 1;