This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Unreviewed patch: Bug in constant folding


Richard Henderson wrote:

>On Thu, Sep 05, 2002 at 08:38:57AM +0200, Hartmut Penner wrote:
>> http://gcc.gnu.org/ml/gcc/2002-03/msg00299.html

>I think the suggested change is correct.  I'm bootstrapping
>with that change now.
OK,
      I prepared a patch, bootstrapped and regtested on S390x.
Also I have a testcase for gcc.c-torture/execute.

OK to commit to mainline?

ChangeLog:

      * fold-const.c (mark_range): Fix for bug in constant folding.

Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.219
diff -c -p -r1.219 fold-const.c
*** fold-const.c  22 Aug 2002 00:42:39 -0000    1.219
--- fold-const.c  12 Sep 2002 06:59:14 -0000
*************** make_range (exp, pin_p, plow, phigh)
*** 3089,3098 ****
            = TYPE_MAX_VALUE (equiv_type) ? TYPE_MAX_VALUE (equiv_type)
              : TYPE_MAX_VALUE (type);

!           high_positive = fold (build (RSHIFT_EXPR, type,
!                                convert (type, high_positive),
!                                convert (type, integer_one_node)));
!
            /* If the low bound is specified, "and" the range with the
             range for which the original unsigned value will be
             positive.  */
--- 3089,3101 ----
            = TYPE_MAX_VALUE (equiv_type) ? TYPE_MAX_VALUE (equiv_type)
              : TYPE_MAX_VALUE (type);

!           /* A shift right by 1 should only be done, if the precision
!              of the unsigned type is higher or equal to the precision
!              we are converting to.  */
!               if (TREE_PRECISION (type) >= TREE_PRECISION (TREE_TYPE (exp)))
!                 high_positive = fold (build (RSHIFT_EXPR, type,
!                                        convert (type, high_positive),
!                                  convert (type, integer_one_node)));
            /* If the low bound is specified, "and" the range with the
             range for which the original unsigned value will be
             positive.  */


Mit freundlichem Gruß / Best regards,

Hartmut Penner
GCC for S/390 Development



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]