aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2001-03-19 18:53:04 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2001-03-19 18:53:04 +0000
commit68e568c28eb6e4d15b06dc23b27168e783ce008c (patch)
treeb54bc88743a41fe139d4d714ef19b50f51dcb79b /gcc/fold-const.c
parentd4b6faf649a1b8f5d84e1e1711a8e66476250de3 (diff)
downloadgcc-68e568c28eb6e4d15b06dc23b27168e783ce008c.zip
gcc-68e568c28eb6e4d15b06dc23b27168e783ce008c.tar.gz
gcc-68e568c28eb6e4d15b06dc23b27168e783ce008c.tar.bz2
cse.c (find_comparison_args): Update documentation.
* cse.c (find_comparison_args): Update documentation. Fix mishandling of COMPARE operations. * tree.def (ABS_EXPR): Add documentation. * fold-const.c (fold): Improve folding of ABS_EXPRs. From-SVN: r40630
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index dda3102..ed98822 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -5275,8 +5275,16 @@ fold (expr)
{
if (TREE_CODE (arg0) == INTEGER_CST)
{
- if (! TREE_UNSIGNED (type)
- && TREE_INT_CST_HIGH (arg0) < 0)
+ /* If the value is unsigned, then the absolute value is
+ the same as the ordinary value. */
+ if (TREE_UNSIGNED (type))
+ return arg0;
+ /* Similarly, if the value is non-negative. */
+ else if (INT_CST_LT (integer_minus_one_node, arg0))
+ return arg0;
+ /* If the value is negative, then the absolute value is
+ its negation. */
+ else
{
unsigned HOST_WIDE_INT low;
HOST_WIDE_INT high;