aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>1999-02-10 17:10:47 -0700
committerJeff Law <law@gcc.gnu.org>1999-02-10 17:10:47 -0700
commitd7b3ea38e00728301f3a99d19338ade660181cf2 (patch)
tree96b65a6ab40550d6a17f0bdc1614cb3c1934aa5e /gcc/fold-const.c
parent708bcaa7b1bf98a8b06abb2959067e62c72a827d (diff)
downloadgcc-d7b3ea38e00728301f3a99d19338ade660181cf2.zip
gcc-d7b3ea38e00728301f3a99d19338ade660181cf2.tar.gz
gcc-d7b3ea38e00728301f3a99d19338ade660181cf2.tar.bz2
fold-const.c (range_binop): Take account of the bounded nature of fixed length arithmetic when...
h * fold-const.c (range_binop): Take account of the bounded nature of fixed length arithmetic when comparing unbounded ranges. From-SVN: r25146
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 9b17374..0dbce12 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -3009,21 +3009,33 @@ range_binop (code, type, arg0, upper0_p, arg1, upper1_p)
return 0;
/* Set SGN[01] to -1 if ARG[01] is a lower bound, 1 for upper, and 0
- for neither. Then compute our result treating them as never equal
- and comparing bounds to non-bounds as above. */
+ for neither. In real maths, we cannot assume open ended ranges are
+ the same. But, this is computer arithmetic, where numbers are finite.
+ We can therefore make the transformation of any unbounded range with
+ the value Z, Z being greater than any representable number. This permits
+ us to treat unbounded ranges as equal. */
sgn0 = arg0 != 0 ? 0 : (upper0_p ? 1 : -1);
sgn1 = arg1 != 0 ? 0 : (upper1_p ? 1 : -1);
switch (code)
{
- case EQ_EXPR: case NE_EXPR:
- result = (code == NE_EXPR);
+ case EQ_EXPR:
+ result = sgn0 == sgn1;
+ break;
+ case NE_EXPR:
+ result = sgn0 != sgn1;
break;
- case LT_EXPR: case LE_EXPR:
+ case LT_EXPR:
result = sgn0 < sgn1;
break;
- case GT_EXPR: case GE_EXPR:
+ case LE_EXPR:
+ result = sgn0 <= sgn1;
+ break;
+ case GT_EXPR:
result = sgn0 > sgn1;
break;
+ case GE_EXPR:
+ result = sgn0 >= sgn1;
+ break;
default:
abort ();
}