* [Bug middle-end/52478] -ftrapv calls the wrong functions in libgcc
2012-03-04 12:59 [Bug middle-end/52478] New: -ftrapv calls the wrong functions in libgcc burnus at gcc dot gnu.org
@ 2012-03-05 10:19 ` rguenth at gcc dot gnu.org
2012-03-05 10:43 ` burnus at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-03-05 10:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52478
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2012-03-05
AssignedTo|unassigned at gcc dot |rguenth at gcc dot gnu.org
|gnu.org |
Ever Confirmed|0 |1
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-03-05 10:18:55 UTC ---
Confirmed, and I think we have a dup for this somewhere, we use OPTAB_LIB_WIDEN
which is of course bogus for the trapv variants. See also PR52353 for
similar mis-generic handling of trapv optabs.
I'll take this one as well for now.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/52478] -ftrapv calls the wrong functions in libgcc
2012-03-04 12:59 [Bug middle-end/52478] New: -ftrapv calls the wrong functions in libgcc burnus at gcc dot gnu.org
2012-03-05 10:19 ` [Bug middle-end/52478] " rguenth at gcc dot gnu.org
@ 2012-03-05 10:43 ` burnus at gcc dot gnu.org
2012-03-05 12:02 ` rguenth at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-03-05 10:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52478
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-03-05 10:42:46 UTC ---
(In reply to comment #1)
> Confirmed, and I think we have a dup for this somewhere.
Maybe PR 35412 - its bug description is a bit unclear. Other bugs related to
this PR have been closed, e.g. PR19020 ("fixed"), PR40143, PR39771, PR36868,
PR27261 (duplicate).
> I'll take this one as well for now.
Thanks!
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/52478] -ftrapv calls the wrong functions in libgcc
2012-03-04 12:59 [Bug middle-end/52478] New: -ftrapv calls the wrong functions in libgcc burnus at gcc dot gnu.org
2012-03-05 10:19 ` [Bug middle-end/52478] " rguenth at gcc dot gnu.org
2012-03-05 10:43 ` burnus at gcc dot gnu.org
@ 2012-03-05 12:02 ` rguenth at gcc dot gnu.org
2012-10-07 19:15 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-03-05 12:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52478
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |NEW
AssignedTo|rguenth at gcc dot gnu.org |unassigned at gcc dot
| |gnu.org
--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-03-05 12:01:23 UTC ---
This seems to be by design, libgcc only provides >= word_mode trapping ops.
Which
means we'd need to expand this all using inline code:
/* Like gen_libfunc, but verify that integer operation is involved. */
static void
gen_int_libfunc (optab optable, const char *opname, char suffix,
enum machine_mode mode)
{
int maxsize = 2 * BITS_PER_WORD;
if (GET_MODE_CLASS (mode) != MODE_INT)
return;
if (maxsize < LONG_LONG_TYPE_SIZE)
maxsize = LONG_LONG_TYPE_SIZE;
if (GET_MODE_CLASS (mode) != MODE_INT
|| mode < word_mode || GET_MODE_BITSIZE (mode) > maxsize)
return;
oops.
Otherwise a simple
Index: gcc/expr.c
===================================================================
--- gcc/expr.c (revision 184918)
+++ gcc/expr.c (working copy)
@@ -8938,7 +8938,9 @@ expand_expr_real_2 (sepops ops, rtx targ
if (modifier == EXPAND_STACK_PARM)
target = 0;
temp = expand_binop (mode, this_optab, op0, op1, target,
- unsignedp, OPTAB_LIB_WIDEN);
+ unsignedp,
+ trapv_binoptab_p (this_optab)
+ ? OPTAB_LIB : OPTAB_LIB_WIDEN);
gcc_assert (temp);
/* Bitwise operations do not need bitfield reduction as we expect their
operands being properly truncated. */
should have worked.
So, it's a "not implemented thing" currently ... unlike to change until
somebody implements the ftrapv proposal from Joseph.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/52478] -ftrapv calls the wrong functions in libgcc
2012-03-04 12:59 [Bug middle-end/52478] New: -ftrapv calls the wrong functions in libgcc burnus at gcc dot gnu.org
` (2 preceding siblings ...)
2012-03-05 12:02 ` rguenth at gcc dot gnu.org
@ 2012-10-07 19:15 ` pinskia at gcc dot gnu.org
2014-07-24 9:17 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-10-07 19:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52478
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mikulas at artax dot
| |karlin.mff.cuni.cz
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-10-07 19:15:25 UTC ---
*** Bug 54846 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/52478] -ftrapv calls the wrong functions in libgcc
2012-03-04 12:59 [Bug middle-end/52478] New: -ftrapv calls the wrong functions in libgcc burnus at gcc dot gnu.org
` (3 preceding siblings ...)
2012-10-07 19:15 ` pinskia at gcc dot gnu.org
@ 2014-07-24 9:17 ` rguenth at gcc dot gnu.org
2014-07-28 8:48 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-07-24 9:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52478
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
It seems that the libgcc functions for SImode are present (at least on x86_64),
so sth like
Index: gcc/optabs.c
===================================================================
--- gcc/optabs.c (revision 212970)
+++ gcc/optabs.c (working copy)
@@ -5559,13 +5559,17 @@ gen_int_libfunc (optab optable, const ch
enum machine_mode mode)
{
int maxsize = 2 * BITS_PER_WORD;
+ int minsize = BITS_PER_WORD;
if (GET_MODE_CLASS (mode) != MODE_INT)
return;
if (maxsize < LONG_LONG_TYPE_SIZE)
maxsize = LONG_LONG_TYPE_SIZE;
- if (GET_MODE_CLASS (mode) != MODE_INT
- || GET_MODE_BITSIZE (mode) < BITS_PER_WORD
+ if (minsize > INT_TYPE_SIZE
+ && (trapv_binoptab_p (optable)
+ || trapv_unoptab_p (optable)))
+ minsize = INT_TYPE_SIZE;
+ if (GET_MODE_BITSIZE (mode) < minsize
|| GET_MODE_BITSIZE (mode) > maxsize)
return;
gen_libfunc (optable, opname, suffix, mode);
Index: gcc/expr.c
===================================================================
--- gcc/expr.c (revision 212970)
+++ gcc/expr.c (working copy)
@@ -9212,7 +9212,9 @@ expand_expr_real_2 (sepops ops, rtx targ
if (modifier == EXPAND_STACK_PARM)
target = 0;
temp = expand_binop (mode, this_optab, op0, op1, target,
- unsignedp, OPTAB_LIB_WIDEN);
+ unsignedp,
+ trapv_binoptab_p (this_optab)
+ ? OPTAB_LIB : OPTAB_LIB_WIDEN);
gcc_assert (temp);
/* Bitwise operations do not need bitfield reduction as we expect their
operands being properly truncated. */
makes the testcase pass.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/52478] -ftrapv calls the wrong functions in libgcc
2012-03-04 12:59 [Bug middle-end/52478] New: -ftrapv calls the wrong functions in libgcc burnus at gcc dot gnu.org
` (4 preceding siblings ...)
2014-07-24 9:17 ` rguenth at gcc dot gnu.org
@ 2014-07-28 8:48 ` rguenth at gcc dot gnu.org
2014-07-28 9:06 ` rguenth at gcc dot gnu.org
2014-07-29 11:11 ` rguenth at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-07-28 8:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52478
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Mon Jul 28 08:47:38 2014
New Revision: 213117
URL: https://gcc.gnu.org/viewcvs?rev=213117&root=gcc&view=rev
Log:
2014-07-28 Richard Biener <rguenther@suse.de>
PR middle-end/52478
* optabs.c (gen_int_libfunc): For -ftrapv libfuncs make
sure to register SImode ones, not only >= word_mode ones.
* expr.c (expand_expr_real_2): When expanding -ftrapv
binops do not use OPTAB_LIB_WIDEN.
* gcc.dg/torture/ftrapv-1.c: New testcase.
Added:
trunk/gcc/testsuite/gcc.dg/torture/ftrapv-1.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/expr.c
trunk/gcc/optabs.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/52478] -ftrapv calls the wrong functions in libgcc
2012-03-04 12:59 [Bug middle-end/52478] New: -ftrapv calls the wrong functions in libgcc burnus at gcc dot gnu.org
` (5 preceding siblings ...)
2014-07-28 8:48 ` rguenth at gcc dot gnu.org
@ 2014-07-28 9:06 ` rguenth at gcc dot gnu.org
2014-07-29 11:11 ` rguenth at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-07-28 9:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52478
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Known to work| |4.10.0
Resolution|--- |FIXED
Target Milestone|--- |4.10.0
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed on trunk.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/52478] -ftrapv calls the wrong functions in libgcc
2012-03-04 12:59 [Bug middle-end/52478] New: -ftrapv calls the wrong functions in libgcc burnus at gcc dot gnu.org
` (6 preceding siblings ...)
2014-07-28 9:06 ` rguenth at gcc dot gnu.org
@ 2014-07-29 11:11 ` rguenth at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-07-29 11:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52478
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Tue Jul 29 11:10:49 2014
New Revision: 213153
URL: https://gcc.gnu.org/viewcvs?rev=213153&root=gcc&view=rev
Log:
2014-07-29 Richard Biener <rguenther@suse.de>
PR middle-end/52478
* expr.c (expand_expr_real_2): Revert last change.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/expr.c
^ permalink raw reply [flat|nested] 9+ messages in thread