This is the mail archive of the gcc@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: suspect code in fold-const.c


On 11/14/13 09:16, Kenneth Zadeck wrote:
in doing the wide int conversion, i have found the following code on the
trunk which seems somewhat suspect:


this code from fold-const.c starts on line 13811.

         else if (TREE_INT_CST_HIGH (arg1) == signed_max_hi
              && TREE_INT_CST_LOW (arg1) == signed_max_lo
              && TYPE_UNSIGNED (arg1_type)
              /* We will flip the signedness of the comparison operator
             associated with the mode of arg1, so the sign bit is
             specified by this mode.  Check that arg1 is the signed
             max associated with this sign bit.  */
              && width == GET_MODE_BITSIZE (TYPE_MODE (arg1_type))
              /* signed_type does not work on pointer types.  */
              && INTEGRAL_TYPE_P (arg1_type))

it seems that the check on bitsize should really be a check on the
precision of the variable.   If this seems right, i will correct this on
the trunk and make the appropriate changes to the wide-int branch.
I'd strongly suggest talking with Eric. It looks like the mode test is on purpose. From the change which introduced that code:

commit 8aa01816af90c5c9b6e3718ee263678ce5f3d93e Author: ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Fri Dec 1 22:46:45 2006 +0000


        * fold-const.c (fold_binary) <LT_EXPR>: Use the precision of the
        type instead of the size of its mode to compute the highest and
        lowest possible values.  Still check the size of the mode before
        flipping the signedness of the comparison.



git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@119422 138bc75d-0d04-0410-96

And it's associated thread on gcc-patches:


http://gcc.gnu.org/ml/gcc-patches/2006-11/msg00242.html


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