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: Bad choices by expand_mult_highpart


Ulrich Weigand <weigand@i1.informatik.uni-erlangen.de> writes:

> Richard Sandiford wrote:
> 
> >        * expmed.c (choose_mult_variant, expand_mult_const): New, split from...
> >        (expand_mult): ...here.
> >        (extract_high_half): New, split out from expand_mult_highpart.
> >        (expand_highpart_optab): Likewise.  Don't clobber target prematurely.
> >        (expand_highpart): Evaluate the cost of a shift/add sequence,
> >        then see if any of the specialized optabs are cheaper.
> 
> This somehow yields incorrect arithmetic results on s390x; the test case:
> 
> long var = 1998;
> 
> int main (void)
> {
>   printf ("%ld %ld\n", var / 60, var % 60);
>   return 0;
> }
> 
> now returns
> 95 -3702
> instead of
> 33 18
> 
> I haven't quite understood why yet (in fact, I haven't quite understood the
> whole division-by-multiplication logic in detail yet), but reverting your
> patch makes the problem go away ...
> 
> Any idea?
> 
> Bye,
> Ulrich
> 
> -- 
>   Dr. Ulrich Weigand
>   weigand@informatik.uni-erlangen.de

 Have you filed a bug against this yet?  This looks really similar to what
is causing my bootstrap failure on sparc-linux.

Jim


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