From 97f33ffd0a6e743d6b4bb2a656cc66d1a0a1fa71 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Tue, 8 Apr 2008 22:07:20 +0000 Subject: [PATCH] re PR tree-optimization/35833 (Wrong code generated with -ftree-vrp) 2008-04-05 Richard Guenther PR tree-optimization/35833 * tree-vrp.c (operand_less_p): Deal with non-INTEGER_CST results from fold_binary_to_constant. (compare_values_warnv): Likewise. * gcc.dg/torture/pr35833.c: New testcase. From-SVN: r134111 --- gcc/ChangeLog | 5 +++++ gcc/fold-const.c | 6 +++++- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.c-torture/execute/20080408-1.c | 11 +++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/20080408-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9fdf703d4f7f..36e7853b765b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2008-04-08 Richard Guenther + + * fold-const.c (fold_widened_comparison): Do not allow + sign-changes that change the result. + 2008-04-03 Bob Wilson * config/xtensa/xtensa.c (xtensa_secondary_reload_class): Use a diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 23523debf41f..dde8f88720a0 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -6663,7 +6663,11 @@ fold_widened_comparison (enum tree_code code, tree type, tree arg0, tree arg1) || TYPE_UNSIGNED (TREE_TYPE (arg0)) == TYPE_UNSIGNED (shorter_type)) && (TREE_TYPE (arg1_unw) == shorter_type || (TYPE_PRECISION (shorter_type) - >= TYPE_PRECISION (TREE_TYPE (arg1_unw))) + > TYPE_PRECISION (TREE_TYPE (arg1_unw))) + || ((TYPE_PRECISION (shorter_type) + == TYPE_PRECISION (TREE_TYPE (arg1_unw))) + && (TYPE_UNSIGNED (shorter_type) + == TYPE_UNSIGNED (TREE_TYPE (arg1_unw)))) || (TREE_CODE (arg1_unw) == INTEGER_CST && (TREE_CODE (shorter_type) == INTEGER_TYPE || TREE_CODE (shorter_type) == BOOLEAN_TYPE) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8c8f5840357b..ad991a5b532d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-04-08 Richard Guenther + + * gcc.c-torture/execute/20080408-1.c: New testcase. + 2008-04-01 Laurent GUERBY * ada/acats/norun.lst: Add c9a011b. diff --git a/gcc/testsuite/gcc.c-torture/execute/20080408-1.c b/gcc/testsuite/gcc.c-torture/execute/20080408-1.c new file mode 100644 index 000000000000..9e1ff6395174 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20080408-1.c @@ -0,0 +1,11 @@ +extern void abort (void); +int main () +{ + short ssi = 126; + unsigned short usi = 65280; + int fail = !(ssi < usi); + if (fail) + abort (); + return 0; +} + -- 2.47.2