]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ifcvt.c (noce_try_store_flag_constants): Test for overflow in computing DIFF.
authorRichard Henderson <rth@redhat.com>
Tue, 27 Nov 2001 09:07:59 +0000 (01:07 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Tue, 27 Nov 2001 09:07:59 +0000 (01:07 -0800)
        * ifcvt.c (noce_try_store_flag_constants): Test for overflow
        in computing DIFF.

From-SVN: r47374

gcc/ChangeLog
gcc/ifcvt.c

index 2d6093552dcc6a644253c1231e6c9d6e1e6b5873..ab355387288f2d37f88f98af2a1b6af5771d26e2 100644 (file)
@@ -1,3 +1,8 @@
+2001-11-27  Richard Henderson  <rth@redhat.com>
+
+       * ifcvt.c (noce_try_store_flag_constants): Test for overflow
+       in computing DIFF.
+
 2001-11-27  Zack Weinberg  <zack@codesourcery.com>
 
        * cppfiles.c (read_include_file): Add comment.
index 5dd42fc8d7efa9c0dd5b1a5538118b808909feab..f6a07e9667078ff54b667b9cec32389170f6fdf7 100644 (file)
@@ -650,6 +650,12 @@ noce_try_store_flag_constants (if_info)
       mode = GET_MODE (if_info->x);
       ifalse = INTVAL (if_info->a);
       itrue = INTVAL (if_info->b);
+
+      /* Make sure we can represent the difference between the two values.  */
+      if ((itrue - ifalse > 0)
+         != ((ifalse < 0) != (itrue < 0) ? ifalse < 0 : ifalse < itrue))
+       return FALSE;
+
       diff = trunc_int_for_mode (itrue - ifalse, mode);
 
       can_reverse = (reversed_comparison_code (if_info->cond, if_info->jump)