]> gcc.gnu.org Git - gcc.git/commitdiff
fold-const.c (fold_truthop): When changing a one-bit comparison against zero into...
authorJ"orn Rennecke <amylaar@cygnus.co.uk>
Thu, 13 Nov 1997 00:09:37 +0000 (00:09 +0000)
committerJoern Rennecke <amylaar@gcc.gnu.org>
Thu, 13 Nov 1997 00:09:37 +0000 (00:09 +0000)
* fold-const.c (fold_truthop): When changing a one-bit comparison
against zero into a comparison against mask, do a proper sign
extension.

From-SVN: r16448

gcc/ChangeLog
gcc/fold-const.c

index 0893da34b14aa8e29c0660e244969b834c0ac273..af1f8f2bb40b2459cd06c0ae4959dd5462f15993 100644 (file)
@@ -1,3 +1,9 @@
+Thu Nov 13 00:06:58 1997  J"orn Rennecke <amylaar@cygnus.co.uk>
+
+       * fold-const.c (fold_truthop): When changing a one-bit comparison
+       against zero into a comparison against mask, do a proper sign
+       extension.
+
 Wed Nov 12 09:37:01 1997  Jeffrey A Law  (law@cygnus.com)
 
        * except.c: Do not include "assert.h".
index 3ce114bb4ade80602780b33f5736cfc71f0da1b5..9b342528f8acd21b885adf2778d8707250e6c3b9 100644 (file)
@@ -3424,7 +3424,17 @@ fold_truthop (code, truth_type, lhs, rhs)
   if (lcode != wanted_code)
     {
       if (l_const && integer_zerop (l_const) && integer_pow2p (ll_mask))
-       l_const = ll_mask;
+       {
+         if (ll_unsignedp)
+           l_const = ll_mask;
+       else
+         /* Since ll_arg is a single bit bit mask, we can sign extend
+            it appropriately with a NEGATE_EXPR.
+            l_const is made a signed value here, but since for l_const != NULL
+            lr_unsignedp is not used, we don't need to clear the latter.  */
+         l_const = fold (build1 (NEGATE_EXPR, TREE_TYPE (ll_arg),
+                                 convert (TREE_TYPE (ll_arg), ll_mask)));
+       }
       else
        return 0;
     }
@@ -3432,7 +3442,14 @@ fold_truthop (code, truth_type, lhs, rhs)
   if (rcode != wanted_code)
     {
       if (r_const && integer_zerop (r_const) && integer_pow2p (rl_mask))
-       r_const = rl_mask;
+       {
+         if (rl_unsignedp)
+           r_const = rl_mask;
+       else
+         /* This is analogous to the code for l_const above.  */
+         r_const = fold (build1 (NEGATE_EXPR, TREE_TYPE (rl_arg),
+                                 convert (TREE_TYPE (rl_arg), rl_mask)));
+       }
       else
        return 0;
     }
This page took 0.087369 seconds and 5 git commands to generate.