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: About GSOC.


Hello.
As further part of implementing roundeven is inlining, I was studying
machine descriptions and I have a few questions.

As suggested, builtin functions provided a strong model for
implementing roundeven. Keeping that in mind, I tried to inspect how
similar functions (round/ceil) would get inlined. As it is dependent
on target machine, (mine is i7, so should be x86_64 ? I wonder why
gcc/config/ does not have x86_64 or amd64 directory. Or is it i386
itself as extended?), should *.s file after compilation contain the
specific instruction if supported? I was unable to see such kind of
instruction on any -O level.

Different pattern names are available for machine descriptions
<https://gcc.gnu.org/onlinedocs/gccint/Standard-Names.html>, also for
round, ceil, etc. Will I have to add such pattern name for roundeven?
(is it the same as optab defined in optabs.def?)

Thanks,
-Tejas


On Thu, 13 Jun 2019 at 00:27, Tejas Joshi <tejasjoshi9673@gmail.com> wrote:
>
> Hello.
>
> > I don't think you should have the unreachable "return false;" in is_even.
> > The last "else if" can just be "else".
>
> I don't think return false in is_even is unreachable. As per my
> understanding, when one else if is true in the else if ladder, all the
> subsequent "else ifs" including "else" are ignored. When REAL_EXP is
> less than SIGNIFICAND_BITS, but the number is odd, the inner "if" for
> even-odd will not return true in which case should return false. That
> case will ignore next "else if" and will reach return false.
>
> > Suppose REAL_EXP (r) > SIGNIFICAND_BITS.  Then the number is definitely
> > even, so you should return true, not false.
>
> for this condition, else if can be modified to just else and return true.
> PATCH:
>
> gcc/ChangeLog:
>
> 2019-06-12  Tejas Joshi  <tejasjoshi9673@gmail.com>
>
>     * builtins.c (mathfn_built_in_2): Added CASE_MATHFN for ROUNDEVEN.
>     * builtins.def: Added function definitions for roundeven function
>     variants.
>     * fold-const-call.c (fold_const_call_ss): Added case for function
>     call and fold_const_conversion call for roundeven function.
>     * fold-const.c (negate_mathfn_p): Added case for roundeven function.
>     (tree_call_nonnegative_warnv_p): Added case for roundeven function.
>     (integer_valued_real_call_p): Added case for roundeven function.
>     * real.c (is_even): New function. Returns true if real number is
>     even, otherwise returns false.
>     (is_halfway_below): New function. Returns true if real number is
>     halfway between two integers, else return false.
>     (real_roundeven): New function. Round real number to nearest
>     integer, rounding halfway cases towards even.
>     * real.h (real_value): Added descriptive comments.
>     Added function declaration for roundeven function.
>
> gcc/testsuite/ChangeLog:
>
> 2019-06-12  Tejas Joshi  <tejasjoshi9673@gmail.com>
>
>     * gcc.dg/torture/builtin-round-roundeven.c: New test.
>     * gcc.dg/torture/builtin-round-roundevenf128.c: New test.
>
>
>
> On Tue, 11 Jun 2019 at 01:56, Joseph Myers <joseph@codesourcery.com> wrote:
> >
> > On Sun, 9 Jun 2019, Tejas Joshi wrote:
> >
> > > Hello.
> > > I have created another patch which addresses the above points,
> > > attached herewith.
> >
> > I don't think you should have the unreachable "return false;" in is_even.
> > The last "else if" can just be "else".
> >
> > > > a conditional with < not <=; if REAL_EXP (r) == SIGNIFICAND_BITS, the
> > > > least significant bit has value 1 and the number must be an integer).
> > >
> > > The number is integer because of the whole word spaces is occupied by
> > > integer part?
> > > Also, why would the least significant bit will have value 1 if
> > > REAL_EXP (r) == SIGNIFICAND_BITS, as it only concerns with 2^0th
> > > position (even or odd)?
> >
> > My understanding is that the significand is, as per the comments in
> > real.c, in the range [0.5, 1.0).  There are SIGNIFICAND_BITS bits.  The
> > bit above the most significant one has value 2^REAL_EXP.  The most
> > significant one has value 2^(REAL_EXP-1).  The least significant one has
> > value 2^(REAL_EXP-SIGNIFICAND_BITS).  If REAL_EXP == SIGNIFICAND_BITS,
> > that means the least significant bit has value 2^0 = 1, and there are no
> > bits with value 0.5 or below, so the number is an integer.
> >
> > --
> > Joseph S. Myers
> > joseph@codesourcery.com


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