public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/64182] New: [5 Regression] wide-int rounding division is broken
@ 2014-12-04 12:30 rguenth at gcc dot gnu.org
2014-12-04 12:31 ` [Bug middle-end/64182] " rguenth at gcc dot gnu.org
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-12-04 12:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64182
Bug ID: 64182
Summary: [5 Regression] wide-int rounding division is broken
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: rguenth at gcc dot gnu.org
CC: rsandifo at gcc dot gnu.org
Testcase for gnat.dg/round_div.adb
-- { dg-do run }
-- { dg-options "-O3" }
procedure Round_Div is
type Fixed is delta 1.0 range -2147483648.0 .. 2147483647.0;
A : Fixed := 1.0;
B : Fixed := 3.0;
C : Integer;
function Divide (X, Y : Fixed) return Integer is
begin
return Integer (X / Y);
end;
begin
C := Divide (A, B);
if C /= 0 then
raise Program_Error;
end if;
end Round_Div;
Joseph pointed out round_mod_expr has the same issue.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/64182] [5 Regression] wide-int rounding division is broken
2014-12-04 12:30 [Bug middle-end/64182] New: [5 Regression] wide-int rounding division is broken rguenth at gcc dot gnu.org
@ 2014-12-04 12:31 ` rguenth at gcc dot gnu.org
2014-12-08 19:10 ` jakub at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-12-04 12:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64182
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
Target Milestone|--- |5.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/64182] [5 Regression] wide-int rounding division is broken
2014-12-04 12:30 [Bug middle-end/64182] New: [5 Regression] wide-int rounding division is broken rguenth at gcc dot gnu.org
2014-12-04 12:31 ` [Bug middle-end/64182] " rguenth at gcc dot gnu.org
@ 2014-12-08 19:10 ` jakub at gcc dot gnu.org
2014-12-09 9:00 ` jakub at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-12-08 19:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64182
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 34222
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34222&action=edit
gcc5-pr64182.patch
So like this (completely untested so far)? I'm hoping that remainder can't be
ever for signed numbers equal to minimum signed value and thus hopefully
wi::abs nor lshift of that by 1 should overflow. For UNSIGNED, not sure if
wi::neg_p () is the right test for whether lshift by 1 will overflow.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/64182] [5 Regression] wide-int rounding division is broken
2014-12-04 12:30 [Bug middle-end/64182] New: [5 Regression] wide-int rounding division is broken rguenth at gcc dot gnu.org
2014-12-04 12:31 ` [Bug middle-end/64182] " rguenth at gcc dot gnu.org
2014-12-08 19:10 ` jakub at gcc dot gnu.org
@ 2014-12-09 9:00 ` jakub at gcc dot gnu.org
2014-12-10 14:51 ` rsandifo at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-12-09 9:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64182
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Note that double-int implementation looks broken too, it doesn't consider uns
(negates both anyway if they are "negative"), and it probably doesn't handle
the case of too big remainder either.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/64182] [5 Regression] wide-int rounding division is broken
2014-12-04 12:30 [Bug middle-end/64182] New: [5 Regression] wide-int rounding division is broken rguenth at gcc dot gnu.org
` (2 preceding siblings ...)
2014-12-09 9:00 ` jakub at gcc dot gnu.org
@ 2014-12-10 14:51 ` rsandifo at gcc dot gnu.org
2014-12-10 14:52 ` rsandifo at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2014-12-10 14:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64182
rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2014-12-10
Ever confirmed|0 |1
--- Comment #3 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #1)
> Created attachment 34222 [details]
> gcc5-pr64182.patch
>
> So like this (completely untested so far)? I'm hoping that remainder can't
> be ever for signed numbers equal to minimum signed value and thus hopefully
> wi::abs nor lshift of that by 1 should overflow. For UNSIGNED, not sure if
> wi::neg_p () is the right test for whether lshift by 1 will overflow.
Looks OK to me, but I wonder if we could just use:
wi::geu_p (y, remainder - y)
for unsigned, and similarly with abses for signed, which avoids having to worry
about overflow. Will try.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/64182] [5 Regression] wide-int rounding division is broken
2014-12-04 12:30 [Bug middle-end/64182] New: [5 Regression] wide-int rounding division is broken rguenth at gcc dot gnu.org
` (3 preceding siblings ...)
2014-12-10 14:51 ` rsandifo at gcc dot gnu.org
@ 2014-12-10 14:52 ` rsandifo at gcc dot gnu.org
2014-12-10 15:27 ` jakub at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2014-12-10 14:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64182
--- Comment #4 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
(In reply to rsandifo@gcc.gnu.org from comment #3)
> (In reply to Jakub Jelinek from comment #1)
> > Created attachment 34222 [details]
> > gcc5-pr64182.patch
> >
> > So like this (completely untested so far)? I'm hoping that remainder can't
> > be ever for signed numbers equal to minimum signed value and thus hopefully
> > wi::abs nor lshift of that by 1 should overflow. For UNSIGNED, not sure if
> > wi::neg_p () is the right test for whether lshift by 1 will overflow.
>
> Looks OK to me, but I wonder if we could just use:
>
> wi::geu_p (y, remainder - y)
>
> for unsigned, and similarly with abses for signed, which avoids having to
> worry about overflow. Will try.
Er, of course I mean:
wi::geu_p (remainder, y - remainder)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/64182] [5 Regression] wide-int rounding division is broken
2014-12-04 12:30 [Bug middle-end/64182] New: [5 Regression] wide-int rounding division is broken rguenth at gcc dot gnu.org
` (4 preceding siblings ...)
2014-12-10 14:52 ` rsandifo at gcc dot gnu.org
@ 2014-12-10 15:27 ` jakub at gcc dot gnu.org
2014-12-12 0:59 ` zadeck at naturalbridge dot com
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-12-10 15:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64182
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Makes sense. Will you also fix double-int.c when you are on this?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/64182] [5 Regression] wide-int rounding division is broken
2014-12-04 12:30 [Bug middle-end/64182] New: [5 Regression] wide-int rounding division is broken rguenth at gcc dot gnu.org
` (5 preceding siblings ...)
2014-12-10 15:27 ` jakub at gcc dot gnu.org
@ 2014-12-12 0:59 ` zadeck at naturalbridge dot com
2014-12-12 7:53 ` rsandifo at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: zadeck at naturalbridge dot com @ 2014-12-12 0:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64182
Kenneth Zadeck <zadeck at naturalbridge dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |zadeck at naturalbridge dot com
--- Comment #7 from Kenneth Zadeck <zadeck at naturalbridge dot com> ---
I do believe that it is possible to test the double int code if you wrote a
program that used fixed point math. I have never used fixed point math and
have no interest in doing so, but double it is the implementation platform for
fixed point math.
kenny
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/64182] [5 Regression] wide-int rounding division is broken
2014-12-04 12:30 [Bug middle-end/64182] New: [5 Regression] wide-int rounding division is broken rguenth at gcc dot gnu.org
` (6 preceding siblings ...)
2014-12-12 0:59 ` zadeck at naturalbridge dot com
@ 2014-12-12 7:53 ` rsandifo at gcc dot gnu.org
2014-12-17 12:39 ` mpolacek at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2014-12-12 7:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64182
--- Comment #8 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
(In reply to Kenneth Zadeck from comment #7)
> I do believe that it is possible to test the double int code if you wrote a
> program that used fixed point math. I have never used fixed point math
> and have no interest in doing so, but double it is the implementation
> platform for fixed point math.
Yeah. Richi pointed out in the review that we could just use a GCC plugin to
test it, so I've got a patch for that going through internal review. Using a
plugin is much nicer because it doesn't depend on a non-default language or on
fixed-point support. It also means we can test the wi:: routines directly (in
addition to the Ada testcase, which I'll still commit).
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/64182] [5 Regression] wide-int rounding division is broken
2014-12-04 12:30 [Bug middle-end/64182] New: [5 Regression] wide-int rounding division is broken rguenth at gcc dot gnu.org
` (7 preceding siblings ...)
2014-12-12 7:53 ` rsandifo at gcc dot gnu.org
@ 2014-12-17 12:39 ` mpolacek at gcc dot gnu.org
2015-01-05 10:13 ` [Bug middle-end/64182] " jakub at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-12-17 12:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64182
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org
--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/64182] wide-int rounding division is broken
2014-12-04 12:30 [Bug middle-end/64182] New: [5 Regression] wide-int rounding division is broken rguenth at gcc dot gnu.org
` (8 preceding siblings ...)
2014-12-17 12:39 ` mpolacek at gcc dot gnu.org
@ 2015-01-05 10:13 ` jakub at gcc dot gnu.org
2015-04-22 11:58 ` jakub at gcc dot gnu.org
2015-07-16 9:13 ` rguenth at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-01-05 10:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64182
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[5 Regression] wide-int |wide-int rounding division
|rounding division is broken |is broken
--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think fixed on the trunk, but likely the double-int.c fix has not been
backported to release branches.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/64182] wide-int rounding division is broken
2014-12-04 12:30 [Bug middle-end/64182] New: [5 Regression] wide-int rounding division is broken rguenth at gcc dot gnu.org
` (9 preceding siblings ...)
2015-01-05 10:13 ` [Bug middle-end/64182] " jakub at gcc dot gnu.org
@ 2015-04-22 11:58 ` jakub at gcc dot gnu.org
2015-07-16 9:13 ` rguenth at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-04-22 11:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64182
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|5.0 |5.2
--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 5.1 has been released.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/64182] wide-int rounding division is broken
2014-12-04 12:30 [Bug middle-end/64182] New: [5 Regression] wide-int rounding division is broken rguenth at gcc dot gnu.org
` (10 preceding siblings ...)
2015-04-22 11:58 ` jakub at gcc dot gnu.org
@ 2015-07-16 9:13 ` rguenth at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-07-16 9:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64182
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|5.2 |5.3
--- Comment #13 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 5.2 is being released, adjusting target milestone to 5.3.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2015-07-16 9:11 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-04 12:30 [Bug middle-end/64182] New: [5 Regression] wide-int rounding division is broken rguenth at gcc dot gnu.org
2014-12-04 12:31 ` [Bug middle-end/64182] " rguenth at gcc dot gnu.org
2014-12-08 19:10 ` jakub at gcc dot gnu.org
2014-12-09 9:00 ` jakub at gcc dot gnu.org
2014-12-10 14:51 ` rsandifo at gcc dot gnu.org
2014-12-10 14:52 ` rsandifo at gcc dot gnu.org
2014-12-10 15:27 ` jakub at gcc dot gnu.org
2014-12-12 0:59 ` zadeck at naturalbridge dot com
2014-12-12 7:53 ` rsandifo at gcc dot gnu.org
2014-12-17 12:39 ` mpolacek at gcc dot gnu.org
2015-01-05 10:13 ` [Bug middle-end/64182] " jakub at gcc dot gnu.org
2015-04-22 11:58 ` jakub at gcc dot gnu.org
2015-07-16 9:13 ` rguenth at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).