aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1996-04-14 18:49:18 -0400
committerRichard Kenner <kenner@gcc.gnu.org>1996-04-14 18:49:18 -0400
commit700ad580a6b6b3c53d74a03a75ad6b3ce82b0a41 (patch)
tree168521c0927d2183ac6994e49bee52faaa4d9a8f /gcc
parent84c7be4b21fdb0614ffbf954771b0aa241a7877d (diff)
downloadgcc-700ad580a6b6b3c53d74a03a75ad6b3ce82b0a41.zip
gcc-700ad580a6b6b3c53d74a03a75ad6b3ce82b0a41.tar.gz
gcc-700ad580a6b6b3c53d74a03a75ad6b3ce82b0a41.tar.bz2
(range_test): Don't convert hi_cst or lo_cst to unsigned when folding
signed range tests. From-SVN: r11768
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fold-const.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index d494f64..78da4fb 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -2617,15 +2617,21 @@ range_test (jcode, type, lo_code, hi_code, var, lo_cst, hi_cst)
if (! TREE_UNSIGNED (utype))
{
utype = unsigned_type (utype);
- var = convert (utype, var);
- lo_cst = convert (utype, lo_cst);
- hi_cst = convert (utype, hi_cst);
+ return fold (convert (type,
+ build (rcode, utype,
+ convert (utype,
+ build (MINUS_EXPR, TREE_TYPE (var),
+ var, lo_cst)),
+ convert (utype,
+ const_binop (MINUS_EXPR, hi_cst,
+ lo_cst, 0)))));
}
-
- return fold (convert (type,
- build (rcode, utype,
- build (MINUS_EXPR, utype, var, lo_cst),
- const_binop (MINUS_EXPR, hi_cst, lo_cst, 0))));
+ else
+ return fold (convert (type,
+ build (rcode, utype,
+ build (MINUS_EXPR, utype, var, lo_cst),
+ const_binop (MINUS_EXPR, hi_cst,
+ lo_cst, 0))));
}
/* Subroutine for fold_truthop: C is an INTEGER_CST interpreted as a P