[llvm-commits] [llvm] r71612 - in /llvm/trunk: include/llvm/Support/MathExtras.h lib/Target/Alpha/AlphaInstrInfo.td lib/Transforms/Scalar/LoopStrengthReduce.cpp
Dale Johannesen
dalej at apple.com
Tue May 12 17:24:24 PDT 2009
Author: johannes
Date: Tue May 12 19:24:22 2009
New Revision: 71612
URL: http://llvm.org/viewvc/llvm-project?rev=71612&view=rev
Log:
Add an int64_t variant of abs, for host environments
without one. Use it where we were using abs on
int64_t objects.
(I strongly suspect the casts to unsigned in the
fragments in LoopStrengthReduce are not doing whatever
the original intent was, but the obvious change to
uint64_t doesn't work. Maybe later.)
Modified:
llvm/trunk/include/llvm/Support/MathExtras.h
llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.td
llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Modified: llvm/trunk/include/llvm/Support/MathExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MathExtras.h?rev=71612&r1=71611&r2=71612&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/MathExtras.h (original)
+++ llvm/trunk/include/llvm/Support/MathExtras.h Tue May 12 19:24:22 2009
@@ -425,6 +425,13 @@
return ((Value + Align - 1) / Align) * Align;
}
+/// abs64 - absolute value of a 64-bit int. Not all environments support
+/// "abs" on whatever their name for the 64-bit int type is. The absolute
+/// value of the largest negative number is undefined, as with "abs".
+inline int64_t abs64(int64_t x) {
+ return (x < 0) ? -x : x;
+}
+
} // End llvm namespace
#endif
Modified: llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.td?rev=71612&r1=71611&r2=71612&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.td (original)
+++ llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.td Tue May 12 19:24:22 2009
@@ -69,7 +69,7 @@
}]>;
def nearP2RemX : SDNodeXForm<imm, [{
uint64_t x =
- abs(N->getZExtValue() - getNearPower2((uint64_t)N->getZExtValue()));
+ abs64(N->getZExtValue() - getNearPower2((uint64_t)N->getZExtValue()));
return getI64Imm(Log2_64(x));
}]>;
@@ -124,7 +124,7 @@
getNearPower2((uint64_t)N->getZExtValue()));
}]>;
def immUExt8ME : PatLeaf<(imm), [{ //use this imm for mulqi
- int64_t d = abs((int64_t)N->getZExtValue() -
+ int64_t d = abs64((int64_t)N->getZExtValue() -
(int64_t)getNearPower2((uint64_t)N->getZExtValue()));
if (isPowerOf2_64(d)) return false;
switch (d) {
Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=71612&r1=71611&r2=71612&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Tue May 12 19:24:22 2009
@@ -1013,7 +1013,7 @@
continue;
int64_t SSInt = cast<SCEVConstant>(SI->first)->getValue()->getSExtValue();
if (SI->first != Stride &&
- (unsigned(abs(SInt)) < SSInt || (SInt % SSInt) != 0))
+ (unsigned(abs64(SInt)) < SSInt || (SInt % SSInt) != 0))
continue;
int64_t Scale = SInt / SSInt;
// Check that this stride is valid for all the types used for loads and
@@ -1900,7 +1900,7 @@
continue;
int64_t SSInt = cast<SCEVConstant>(SI->first)->getValue()->getSExtValue();
if (SSInt == CmpSSInt ||
- abs(SSInt) < abs(CmpSSInt) ||
+ abs64(SSInt) < abs64(CmpSSInt) ||
(SSInt % CmpSSInt) != 0)
continue;
@@ -2336,7 +2336,7 @@
cast<SCEVConstant>(SI->first)->getValue()->getSExtValue();
if (SSInt == SInt)
return; // This can definitely be reused.
- if (unsigned(abs(SSInt)) < SInt || (SSInt % SInt) != 0)
+ if (unsigned(abs64(SSInt)) < SInt || (SSInt % SInt) != 0)
continue;
int64_t Scale = SSInt / SInt;
bool AllUsesAreAddresses = true;
More information about the llvm-commits
mailing list