public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/23109] New: compiler generates wrong code leading to spurious division by zero
@ 2005-07-28 10:43 p dot van-hoof at qub dot ac dot uk
2005-07-28 10:45 ` [Bug c/23109] " p dot van-hoof at qub dot ac dot uk
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: p dot van-hoof at qub dot ac dot uk @ 2005-07-28 10:43 UTC (permalink / raw)
To: gcc-bugs
The attached code crashes on a division by zero when compiled as follows:
dogbert> gcc -O1 -funsafe-math-optimizations -ftrapping-math b.c
dogbert> a.out
Floating exception
dogbert> gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/usr/local/gcc410
--enable-languages=c,c++,f95
Thread model: posix
gcc version 4.1.0 20050725 (experimental)
I don't believe that -funsafe-math-optimizations enables -fno-trapping-math, but
to be really sure I added the -ftrapping-math command line option. It makes no
difference.
Taken at face value it looks like the optimizer lifts the division by d outside
the conditional on line 19, even though that could lead to a spurious division
by zero and -ftrapping-math is in effect.
This behavior only shows up on the mainline, and not on the 3.4 and 4.0
branches. A slightly modified version (to enable FP traps on Suns) also crashes
with gcc 4.1.0 on the target sparc-sun-solaris2.9.
--
Summary: compiler generates wrong code leading to spurious
division by zero
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: p dot van-hoof at qub dot ac dot uk
CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23109
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/23109] compiler generates wrong code leading to spurious division by zero
2005-07-28 10:43 [Bug c/23109] New: compiler generates wrong code leading to spurious division by zero p dot van-hoof at qub dot ac dot uk
@ 2005-07-28 10:45 ` p dot van-hoof at qub dot ac dot uk
2005-07-28 15:02 ` rguenth at gcc dot gnu dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: p dot van-hoof at qub dot ac dot uk @ 2005-07-28 10:45 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From p dot van-hoof at qub dot ac dot uk 2005-07-28 10:42 -------
Created an attachment (id=9377)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=9377&action=view)
code that causes the crash
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23109
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/23109] compiler generates wrong code leading to spurious division by zero
2005-07-28 10:43 [Bug c/23109] New: compiler generates wrong code leading to spurious division by zero p dot van-hoof at qub dot ac dot uk
2005-07-28 10:45 ` [Bug c/23109] " p dot van-hoof at qub dot ac dot uk
@ 2005-07-28 15:02 ` rguenth at gcc dot gnu dot org
2005-07-28 15:13 ` rguenth at gcc dot gnu dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-07-28 15:02 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rguenth at gcc dot gnu dot org 2005-07-28 14:47 -------
Indeed unsafe-math-optimization is not the only precondition for this
transformation.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2005-07-28 14:47:37
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23109
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/23109] compiler generates wrong code leading to spurious division by zero
2005-07-28 10:43 [Bug c/23109] New: compiler generates wrong code leading to spurious division by zero p dot van-hoof at qub dot ac dot uk
2005-07-28 10:45 ` [Bug c/23109] " p dot van-hoof at qub dot ac dot uk
2005-07-28 15:02 ` rguenth at gcc dot gnu dot org
@ 2005-07-28 15:13 ` rguenth at gcc dot gnu dot org
2005-07-28 16:56 ` [Bug tree-optimization/23109] [4.1 Regression] compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math) pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-07-28 15:13 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rguenth at gcc dot gnu dot org 2005-07-28 15:01 -------
I have a patch.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |rguenth at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2005-07-28 14:47:37 |2005-07-28 15:01:58
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23109
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/23109] [4.1 Regression] compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math)
2005-07-28 10:43 [Bug c/23109] New: compiler generates wrong code leading to spurious division by zero p dot van-hoof at qub dot ac dot uk
` (2 preceding siblings ...)
2005-07-28 15:13 ` rguenth at gcc dot gnu dot org
@ 2005-07-28 16:56 ` pinskia at gcc dot gnu dot org
2005-08-01 8:53 ` cvs-commit at gcc dot gnu dot org
2005-08-01 8:54 ` rguenth at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-28 16:56 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |minor
Component|c |tree-optimization
Summary|compiler generates wrong |[4.1 Regression] compiler
|code leading to spurious |generates wrong code leading
|division by zero |to spurious division by zero
| |with -funsafe-math-
| |optimizations (instead of -
| |ftrapping-math)
Target Milestone|--- |4.1.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23109
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/23109] [4.1 Regression] compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math)
2005-07-28 10:43 [Bug c/23109] New: compiler generates wrong code leading to spurious division by zero p dot van-hoof at qub dot ac dot uk
` (3 preceding siblings ...)
2005-07-28 16:56 ` [Bug tree-optimization/23109] [4.1 Regression] compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math) pinskia at gcc dot gnu dot org
@ 2005-08-01 8:53 ` cvs-commit at gcc dot gnu dot org
2005-08-01 8:54 ` rguenth at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-08-01 8:53 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-08-01 08:53 -------
Subject: Bug 23109
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: rguenth@gcc.gnu.org 2005-08-01 08:53:00
Modified files:
gcc : ChangeLog tree-ssa-loop-im.c
tree-ssa-math-opts.c
Log message:
2005-08-01 Richard Guenther <rguenther@suse.de>
PR tree-optimization/23109
* tree-ssa-math-opts.c (execute_cse_reciprocals_1):
If trapping math is in effect, use post-dominator information
to check if we'd in any case reach a trapping point before
doing the reciprocal insertion.
(execute_cse_reciprocals): Compute post-dominators, if necessary.
* tree-ssa-loop-im.c (determine_invariantness_stmt): RDIV
expressions are invariant only if trapping math is not in effect.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9622&r2=2.9623
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-loop-im.c.diff?cvsroot=gcc&r1=2.48&r2=2.49
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-math-opts.c.diff?cvsroot=gcc&r1=2.2&r2=2.3
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23109
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/23109] [4.1 Regression] compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math)
2005-07-28 10:43 [Bug c/23109] New: compiler generates wrong code leading to spurious division by zero p dot van-hoof at qub dot ac dot uk
` (4 preceding siblings ...)
2005-08-01 8:53 ` cvs-commit at gcc dot gnu dot org
@ 2005-08-01 8:54 ` rguenth at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-08-01 8:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rguenth at gcc dot gnu dot org 2005-08-01 08:54 -------
Fixed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23109
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-08-01 8:54 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-28 10:43 [Bug c/23109] New: compiler generates wrong code leading to spurious division by zero p dot van-hoof at qub dot ac dot uk
2005-07-28 10:45 ` [Bug c/23109] " p dot van-hoof at qub dot ac dot uk
2005-07-28 15:02 ` rguenth at gcc dot gnu dot org
2005-07-28 15:13 ` rguenth at gcc dot gnu dot org
2005-07-28 16:56 ` [Bug tree-optimization/23109] [4.1 Regression] compiler generates wrong code leading to spurious division by zero with -funsafe-math-optimizations (instead of -ftrapping-math) pinskia at gcc dot gnu dot org
2005-08-01 8:53 ` cvs-commit at gcc dot gnu dot org
2005-08-01 8:54 ` rguenth at gcc dot gnu dot 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).