public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/49914] New: call to abs(long long) in gcc/fold-const.c
@ 2011-07-30 18:13 marc.glisse at normalesup dot org
2011-07-30 18:29 ` [Bug other/49914] " marc.glisse at normalesup dot org
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: marc.glisse at normalesup dot org @ 2011-07-30 18:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49914
Summary: call to abs(long long) in gcc/fold-const.c
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: other
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: marc.glisse@normalesup.org
Hello,
in gcc/fold-const.c (currently line 7051), in function
fold_plusminus_mult_expr:
if (exact_log2 (abs (int11)) > 0 && int01 % int11 == 0
where int11 is a HOST_WIDE_INT. Is this call to abs safe? A few lines above,
abs is computed as x>=0?x:-x.
(don't know how to classify this, but it causes a build failure for me with a
C++98 compiler (ambiguous))
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug other/49914] call to abs(long long) in gcc/fold-const.c
2011-07-30 18:13 [Bug other/49914] New: call to abs(long long) in gcc/fold-const.c marc.glisse at normalesup dot org
@ 2011-07-30 18:29 ` marc.glisse at normalesup dot org
2011-07-31 9:46 ` [Bug bootstrap/49914] " rguenth at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: marc.glisse at normalesup dot org @ 2011-07-30 18:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49914
--- Comment #1 from Marc Glisse <marc.glisse at normalesup dot org> 2011-07-30 18:29:06 UTC ---
Also occurs at gcc/tree-ssa-loop-prefetch.c:797 and in many places in
gcc/tree-ssa-math-opts.c.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug bootstrap/49914] call to abs(long long) in gcc/fold-const.c
2011-07-30 18:13 [Bug other/49914] New: call to abs(long long) in gcc/fold-const.c marc.glisse at normalesup dot org
2011-07-30 18:29 ` [Bug other/49914] " marc.glisse at normalesup dot org
@ 2011-07-31 9:46 ` rguenth at gcc dot gnu.org
2011-08-01 16:37 ` paolo.carlini at oracle dot com
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-07-31 9:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49914
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011.07.31 09:46:21
Component|other |bootstrap
Ever Confirmed|0 |1
--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-07-31 09:46:21 UTC ---
It's not strictly safe.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug bootstrap/49914] call to abs(long long) in gcc/fold-const.c
2011-07-30 18:13 [Bug other/49914] New: call to abs(long long) in gcc/fold-const.c marc.glisse at normalesup dot org
2011-07-30 18:29 ` [Bug other/49914] " marc.glisse at normalesup dot org
2011-07-31 9:46 ` [Bug bootstrap/49914] " rguenth at gcc dot gnu.org
@ 2011-08-01 16:37 ` paolo.carlini at oracle dot com
2011-08-01 16:45 ` joseph at codesourcery dot com
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-08-01 16:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49914
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |paolo.carlini at oracle dot
| |com, rguenth at gcc dot
| |gnu.org
--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-08-01 16:36:54 UTC ---
So, Richard, what shall we do here? Add to tree.h just:
#define ABS(X) ((X >= 0) ? (X) : (-X))
and use it in all those places? Or a static inline? Better name?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug bootstrap/49914] call to abs(long long) in gcc/fold-const.c
2011-07-30 18:13 [Bug other/49914] New: call to abs(long long) in gcc/fold-const.c marc.glisse at normalesup dot org
` (2 preceding siblings ...)
2011-08-01 16:37 ` paolo.carlini at oracle dot com
@ 2011-08-01 16:45 ` joseph at codesourcery dot com
2011-08-01 16:57 ` paolo.carlini at oracle dot com
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: joseph at codesourcery dot com @ 2011-08-01 16:45 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49914
--- Comment #4 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2011-08-01 16:44:52 UTC ---
For HOST_WIDE_INT we want abs_hwi from
<http://gcc.gnu.org/ml/gcc-patches/2011-07/msg02628.html>.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug bootstrap/49914] call to abs(long long) in gcc/fold-const.c
2011-07-30 18:13 [Bug other/49914] New: call to abs(long long) in gcc/fold-const.c marc.glisse at normalesup dot org
` (3 preceding siblings ...)
2011-08-01 16:45 ` joseph at codesourcery dot com
@ 2011-08-01 16:57 ` paolo.carlini at oracle dot com
2011-08-01 17:21 ` paolo.carlini at oracle dot com
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-08-01 16:57 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49914
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-08-01 16:56:33 UTC ---
Ah, excellent. But what happened to that patch, I see it approved but not
committed!?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug bootstrap/49914] call to abs(long long) in gcc/fold-const.c
2011-07-30 18:13 [Bug other/49914] New: call to abs(long long) in gcc/fold-const.c marc.glisse at normalesup dot org
` (4 preceding siblings ...)
2011-08-01 16:57 ` paolo.carlini at oracle dot com
@ 2011-08-01 17:21 ` paolo.carlini at oracle dot com
2011-08-01 19:48 ` paolo.carlini at oracle dot com
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-08-01 17:21 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49914
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-08-01 17:20:57 UTC ---
To be clear: if nobody objects I'm willing to bootstrap and test again that
patch, commit it, and then use abs_hwi in all the places pointed out here.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug bootstrap/49914] call to abs(long long) in gcc/fold-const.c
2011-07-30 18:13 [Bug other/49914] New: call to abs(long long) in gcc/fold-const.c marc.glisse at normalesup dot org
` (5 preceding siblings ...)
2011-08-01 17:21 ` paolo.carlini at oracle dot com
@ 2011-08-01 19:48 ` paolo.carlini at oracle dot com
2011-08-02 8:41 ` rguenther at suse dot de
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-08-01 19:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49914
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
CC|paolo.carlini at oracle dot |
|com |
AssignedTo|unassigned at gcc dot |paolo.carlini at oracle dot
|gnu.org |com
Target Milestone|--- |4.7.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug bootstrap/49914] call to abs(long long) in gcc/fold-const.c
2011-07-30 18:13 [Bug other/49914] New: call to abs(long long) in gcc/fold-const.c marc.glisse at normalesup dot org
` (6 preceding siblings ...)
2011-08-01 19:48 ` paolo.carlini at oracle dot com
@ 2011-08-02 8:41 ` rguenther at suse dot de
2011-08-02 8:43 ` rguenther at suse dot de
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenther at suse dot de @ 2011-08-02 8:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49914
--- Comment #7 from rguenther at suse dot de <rguenther at suse dot de> 2011-08-02 08:40:24 UTC ---
On Mon, 1 Aug 2011, paolo.carlini at oracle dot com wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49914
>
> Paolo Carlini <paolo.carlini at oracle dot com> changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> CC| |paolo.carlini at oracle dot
> | |com, rguenth at gcc dot
> | |gnu.org
>
> --- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-08-01 16:36:54 UTC ---
> So, Richard, what shall we do here? Add to tree.h just:
>
> #define ABS(X) ((X >= 0) ? (X) : (-X))
>
> and use it in all those places? Or a static inline? Better name?
No, I'd say have a abs_hwi in hwint.h and use that (ISTR sebastian pop
adding one in a (pending?) patch)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug bootstrap/49914] call to abs(long long) in gcc/fold-const.c
2011-07-30 18:13 [Bug other/49914] New: call to abs(long long) in gcc/fold-const.c marc.glisse at normalesup dot org
` (7 preceding siblings ...)
2011-08-02 8:41 ` rguenther at suse dot de
@ 2011-08-02 8:43 ` rguenther at suse dot de
2011-08-02 12:33 ` joseph at codesourcery dot com
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenther at suse dot de @ 2011-08-02 8:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49914
--- Comment #8 from rguenther at suse dot de <rguenther at suse dot de> 2011-08-02 08:42:00 UTC ---
On Mon, 1 Aug 2011, paolo.carlini at oracle dot com wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49914
>
> --- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-08-01 17:20:57 UTC ---
> To be clear: if nobody objects I'm willing to bootstrap and test again that
> patch, commit it, and then use abs_hwi in all the places pointed out here.
well, I don't think we want the assert in abs_hwi as it stands now.
Either we can handle this case in the callers or we should just do
what we can - exploit the undefined behavior and return INT_MIN for
INT_MIN.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug bootstrap/49914] call to abs(long long) in gcc/fold-const.c
2011-07-30 18:13 [Bug other/49914] New: call to abs(long long) in gcc/fold-const.c marc.glisse at normalesup dot org
` (8 preceding siblings ...)
2011-08-02 8:43 ` rguenther at suse dot de
@ 2011-08-02 12:33 ` joseph at codesourcery dot com
2011-08-02 20:28 ` paolo at gcc dot gnu.org
2011-08-02 20:32 ` paolo.carlini at oracle dot com
11 siblings, 0 replies; 13+ messages in thread
From: joseph at codesourcery dot com @ 2011-08-02 12:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49914
--- Comment #9 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2011-08-02 12:32:24 UTC ---
On Tue, 2 Aug 2011, rguenther at suse dot de wrote:
> well, I don't think we want the assert in abs_hwi as it stands now.
> Either we can handle this case in the callers or we should just do
> what we can - exploit the undefined behavior and return INT_MIN for
> INT_MIN.
If a caller is prepared to get a negative value back from abs_hwi, then an
abs_hwi_wrap version would seem appropriate for such a caller (or a
version that returns unsigned HOST_WIDE_INT, if the callers are written to
work with unsigned values). If a caller expects the result to be positive
and always the absolute value (but of a signed type), it's a bug in the
caller to pass the least HOST_WIDE_INT value, and the assert serves to
detect such a bug in the caller.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug bootstrap/49914] call to abs(long long) in gcc/fold-const.c
2011-07-30 18:13 [Bug other/49914] New: call to abs(long long) in gcc/fold-const.c marc.glisse at normalesup dot org
` (9 preceding siblings ...)
2011-08-02 12:33 ` joseph at codesourcery dot com
@ 2011-08-02 20:28 ` paolo at gcc dot gnu.org
2011-08-02 20:32 ` paolo.carlini at oracle dot com
11 siblings, 0 replies; 13+ messages in thread
From: paolo at gcc dot gnu.org @ 2011-08-02 20:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49914
--- Comment #10 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2011-08-02 20:27:00 UTC ---
Author: paolo
Date: Tue Aug 2 20:26:57 2011
New Revision: 177212
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=177212
Log:
2011-08-02 Paolo Carlini <paolo.carlini@oracle.com>
PR bootstrap/49914
* fold-const.c (fold_plusminus_mult_expr): Use abs_hwi instead
of abs.
* tree-ssa-math-opts.c (gimple_expand_builtin_pow): Likewise.
* tree-ssa-loop-prefetch.c (prune_ref_by_group_reuse): Likewise.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/fold-const.c
trunk/gcc/tree-ssa-loop-prefetch.c
trunk/gcc/tree-ssa-math-opts.c
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug bootstrap/49914] call to abs(long long) in gcc/fold-const.c
2011-07-30 18:13 [Bug other/49914] New: call to abs(long long) in gcc/fold-const.c marc.glisse at normalesup dot org
` (10 preceding siblings ...)
2011-08-02 20:28 ` paolo at gcc dot gnu.org
@ 2011-08-02 20:32 ` paolo.carlini at oracle dot com
11 siblings, 0 replies; 13+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-08-02 20:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49914
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #11 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-08-02 20:31:09 UTC ---
Fixed. I hope it helps a little bit also the __cplusplus issue...
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2011-08-02 20:32 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-30 18:13 [Bug other/49914] New: call to abs(long long) in gcc/fold-const.c marc.glisse at normalesup dot org
2011-07-30 18:29 ` [Bug other/49914] " marc.glisse at normalesup dot org
2011-07-31 9:46 ` [Bug bootstrap/49914] " rguenth at gcc dot gnu.org
2011-08-01 16:37 ` paolo.carlini at oracle dot com
2011-08-01 16:45 ` joseph at codesourcery dot com
2011-08-01 16:57 ` paolo.carlini at oracle dot com
2011-08-01 17:21 ` paolo.carlini at oracle dot com
2011-08-01 19:48 ` paolo.carlini at oracle dot com
2011-08-02 8:41 ` rguenther at suse dot de
2011-08-02 8:43 ` rguenther at suse dot de
2011-08-02 12:33 ` joseph at codesourcery dot com
2011-08-02 20:28 ` paolo at gcc dot gnu.org
2011-08-02 20:32 ` paolo.carlini at oracle dot com
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).