public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/40019] New: LEADZ and TRAILZ give wrong results
@ 2009-05-04 19:36 fxcoudert at gcc dot gnu dot org
2009-05-19 22:24 ` [Bug fortran/40019] " fxcoudert at gcc dot gnu dot org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2009-05-04 19:36 UTC (permalink / raw)
To: gcc-bugs
LEADZ and TRAILZ can give wrong results for kinds other than 4 and 8. For
example, the following code:
integer(kind=1) :: i1
integer(kind=2) :: i2
integer(kind=4) :: i4
integer(kind=8) :: i8
integer(kind=16) :: i16
i1 = -1
i2 = -1
i4 = -1
i8 = -1
i16 = -1
print *, leadz(i1), leadz(i2), leadz(i4), leadz(i8), leadz(i16)
gives " -24 -16 0 0 64" as results,
while it should only yield zeros!
There are a few reasons:
- for kinds 1 and 2, we should not cast directly to (unsigned int), but do a
double cast: (unsigned int)(unsigned char) for kind=1, for example; otherwise,
negative values are screwed.
- trans-intrinsic.c uses a correspondance, kinds == 1, 2 and 4 use
BUILT_IN_CLZ, kind 8 uses BUILT_IN_CLZL and kind 16 uses BUILT_IN_CLZLL; in
reality, there is no such correspondance, as kind==16 is larger than long long!
This, of course, makes it harder, because there is no function ready for use in
kind==16.
--
Summary: LEADZ and TRAILZ give wrong results
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fxcoudert at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40019
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/40019] LEADZ and TRAILZ give wrong results
2009-05-04 19:36 [Bug fortran/40019] New: LEADZ and TRAILZ give wrong results fxcoudert at gcc dot gnu dot org
@ 2009-05-19 22:24 ` fxcoudert at gcc dot gnu dot org
2009-05-27 7:45 ` burnus at gcc dot gnu dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2009-05-19 22:24 UTC (permalink / raw)
To: gcc-bugs
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |fxcoudert at gcc dot gnu dot
|dot org |org
URL| |http://gcc.gnu.org/ml/gcc-
| |patches/2009-
| |05/msg01267.html
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Keywords| |patch
Last reconfirmed|0000-00-00 00:00:00 |2009-05-19 22:24:12
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40019
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/40019] LEADZ and TRAILZ give wrong results
2009-05-04 19:36 [Bug fortran/40019] New: LEADZ and TRAILZ give wrong results fxcoudert at gcc dot gnu dot org
2009-05-19 22:24 ` [Bug fortran/40019] " fxcoudert at gcc dot gnu dot org
@ 2009-05-27 7:45 ` burnus at gcc dot gnu dot org
2009-05-27 10:28 ` fxcoudert at gcc dot gnu dot org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-05-27 7:45 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from burnus at gcc dot gnu dot org 2009-05-27 07:44 -------
I don't think your patch fixes the following,
print *, leadz(-1_1), leadz(-1_2), leadz(-1_4), leadz(-1_8), leadz(-1_16)
which yields
7 15 31 63 127
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40019
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/40019] LEADZ and TRAILZ give wrong results
2009-05-04 19:36 [Bug fortran/40019] New: LEADZ and TRAILZ give wrong results fxcoudert at gcc dot gnu dot org
2009-05-19 22:24 ` [Bug fortran/40019] " fxcoudert at gcc dot gnu dot org
2009-05-27 7:45 ` burnus at gcc dot gnu dot org
@ 2009-05-27 10:28 ` fxcoudert at gcc dot gnu dot org
2009-05-29 21:28 ` burnus at gcc dot gnu dot org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2009-05-27 10:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from fxcoudert at gcc dot gnu dot org 2009-05-27 10:27 -------
(In reply to comment #1)
> I don't think your patch fixes the following,
>
> print *, leadz(-1_1), leadz(-1_2), leadz(-1_4), leadz(-1_8), leadz(-1_16)
>
> which yields
>
> 7 15 31 63 127
I think it does:
$ cat h.f90
print *, leadz(-1_1), leadz(-1_2), leadz(-1_4), leadz(-1_8), leadz(-1_16)
end
$ gfortran h.f90 && ./a.out
0 0 0 0 0
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40019
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/40019] LEADZ and TRAILZ give wrong results
2009-05-04 19:36 [Bug fortran/40019] New: LEADZ and TRAILZ give wrong results fxcoudert at gcc dot gnu dot org
` (2 preceding siblings ...)
2009-05-27 10:28 ` fxcoudert at gcc dot gnu dot org
@ 2009-05-29 21:28 ` burnus at gcc dot gnu dot org
2009-05-29 21:34 ` burnus at gcc dot gnu dot org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-05-29 21:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from burnus at gcc dot gnu dot org 2009-05-29 21:28 -------
Subject: Bug 40019
Author: burnus
Date: Fri May 29 21:27:54 2009
New Revision: 147987
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=147987
Log:
2009-05-29 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/40019
* trans-types.c (gfc_build_uint_type): Make nonstatic.
* trans.h (gfor_fndecl_clz128, gfor_fndecl_ctz128): New
* prototypes.
* trans-types.h (gfc_build_uint_type): Add prototype.
* trans-decl.c (gfc_build_intrinsic_function_decls): Build
gfor_fndecl_clz128 and gfor_fndecl_ctz128.
* trans-intrinsic.c (gfc_conv_intrinsic_leadz,
gfc_conv_intrinsic_trailz): Call the right builtins or library
functions, and cast arguments to unsigned types first.
* simplify.c (gfc_simplify_leadz): Deal with negative arguments.
2009-05-29 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/40019
* intrinsics/bit_intrinsics.c: New file.
* gfortran.map (GFORTRAN_1.2): New list.
* Makefile.am: Add intrinsics/bit_intrinsics.c.
* Makefile.in: Regenerate.
2009-05-29 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/40019
* gfortran.dg/leadz_trailz_1.f90: New test.
* gfortran.dg/leadz_trailz_2.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/leadz_trailz_1.f90
trunk/gcc/testsuite/gfortran.dg/leadz_trailz_2.f90
trunk/libgfortran/intrinsics/bit_intrinsics.c
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/simplify.c
trunk/gcc/fortran/trans-decl.c
trunk/gcc/fortran/trans-intrinsic.c
trunk/gcc/fortran/trans-types.c
trunk/gcc/fortran/trans-types.h
trunk/gcc/fortran/trans.h
trunk/gcc/testsuite/ChangeLog
trunk/libgfortran/ChangeLog
trunk/libgfortran/Makefile.am
trunk/libgfortran/Makefile.in
trunk/libgfortran/gfortran.map
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40019
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/40019] LEADZ and TRAILZ give wrong results
2009-05-04 19:36 [Bug fortran/40019] New: LEADZ and TRAILZ give wrong results fxcoudert at gcc dot gnu dot org
` (3 preceding siblings ...)
2009-05-29 21:28 ` burnus at gcc dot gnu dot org
@ 2009-05-29 21:34 ` burnus at gcc dot gnu dot org
2009-06-03 19:39 ` [Bug fortran/40019] [4.4 only] " burnus at gcc dot gnu dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-05-29 21:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from burnus at gcc dot gnu dot org 2009-05-29 21:33 -------
Checked into the trunk (4.5). Keep open for potential back porting to 4.4.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40019
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/40019] [4.4 only] LEADZ and TRAILZ give wrong results
2009-05-04 19:36 [Bug fortran/40019] New: LEADZ and TRAILZ give wrong results fxcoudert at gcc dot gnu dot org
` (4 preceding siblings ...)
2009-05-29 21:34 ` burnus at gcc dot gnu dot org
@ 2009-06-03 19:39 ` burnus at gcc dot gnu dot org
2009-06-03 19:40 ` [Bug fortran/40019] " burnus at gcc dot gnu dot org
2009-06-03 19:56 ` rguenth at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-06-03 19:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from burnus at gcc dot gnu dot org 2009-06-03 19:39 -------
Subject: Bug 40019
Author: burnus
Date: Wed Jun 3 19:39:09 2009
New Revision: 148143
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=148143
Log:
2009-06-03 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/40019
* trans-types.c (gfc_build_uint_type): Make nonstatic.
* trans.h (gfor_fndecl_clz128, gfor_fndecl_ctz128): New
* prototypes.
* trans-types.h (gfc_build_uint_type): Add prototype.
* trans-decl.c (gfc_build_intrinsic_function_decls): Build
gfor_fndecl_clz128 and gfor_fndecl_ctz128.
* trans-intrinsic.c (gfc_conv_intrinsic_leadz,
gfc_conv_intrinsic_trailz): Call the right builtins or library
functions, and cast arguments to unsigned types first.
* simplify.c (gfc_simplify_leadz): Deal with negative arguments.
2009-06-03 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/40019
* intrinsics/bit_intrinsics.c: New file.
* gfortran.map (GFORTRAN_1.2): New list.
* Makefile.am: Add intrinsics/bit_intrinsics.c.
* Makefile.in: Regenerate.
2009-06-03 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/40019
* gfortran.dg/leadz_trailz_1.f90: New test.
* gfortran.dg/leadz_trailz_2.f90: New test.
-- Diese und die folgenden Zeilen werden ignoriert --
M libgfortran/Makefile.in
A libgfortran/intrinsics/bit_intrinsics.c
M libgfortran/ChangeLog
M libgfortran/gfortran.map
M libgfortran/Makefile.am
M gcc/testsuite/ChangeLog
A gcc/testsuite/gfortran.dg/leadz_trailz_2.f90
A gcc/testsuite/gfortran.dg/leadz_trailz_1.f90
M gcc/fortran/ChangeLog
M gcc/fortran/trans-types.c
M gcc/fortran/trans.h
M gcc/fortran/trans-types.h
M gcc/fortran/trans-decl.c
M gcc/fortran/trans-intrinsic.c
M gcc/fortran/simplify.c
Added:
branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/leadz_trailz_1.f90
branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/leadz_trailz_2.f90
branches/gcc-4_4-branch/libgfortran/intrinsics/bit_intrinsics.c
Modified:
branches/gcc-4_4-branch/gcc/fortran/ChangeLog
branches/gcc-4_4-branch/gcc/fortran/simplify.c
branches/gcc-4_4-branch/gcc/fortran/trans-decl.c
branches/gcc-4_4-branch/gcc/fortran/trans-intrinsic.c
branches/gcc-4_4-branch/gcc/fortran/trans-types.c
branches/gcc-4_4-branch/gcc/fortran/trans-types.h
branches/gcc-4_4-branch/gcc/fortran/trans.h
branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
branches/gcc-4_4-branch/libgfortran/ChangeLog
branches/gcc-4_4-branch/libgfortran/Makefile.am
branches/gcc-4_4-branch/libgfortran/Makefile.in
branches/gcc-4_4-branch/libgfortran/gfortran.map
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40019
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/40019] LEADZ and TRAILZ give wrong results
2009-05-04 19:36 [Bug fortran/40019] New: LEADZ and TRAILZ give wrong results fxcoudert at gcc dot gnu dot org
` (5 preceding siblings ...)
2009-06-03 19:39 ` [Bug fortran/40019] [4.4 only] " burnus at gcc dot gnu dot org
@ 2009-06-03 19:40 ` burnus at gcc dot gnu dot org
2009-06-03 19:56 ` rguenth at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-06-03 19:40 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from burnus at gcc dot gnu dot org 2009-06-03 19:40 -------
Now also FIXED on the 4.4 branch. -> CLOSE
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Summary|[4.4 only] LEADZ and TRAILZ |LEADZ and TRAILZ give wrong
|give wrong results |results
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40019
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/40019] LEADZ and TRAILZ give wrong results
2009-05-04 19:36 [Bug fortran/40019] New: LEADZ and TRAILZ give wrong results fxcoudert at gcc dot gnu dot org
` (6 preceding siblings ...)
2009-06-03 19:40 ` [Bug fortran/40019] " burnus at gcc dot gnu dot org
@ 2009-06-03 19:56 ` rguenth at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-06-03 19:56 UTC (permalink / raw)
To: gcc-bugs
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |4.4.0
Target Milestone|--- |4.4.1
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40019
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-06-03 19:56 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-04 19:36 [Bug fortran/40019] New: LEADZ and TRAILZ give wrong results fxcoudert at gcc dot gnu dot org
2009-05-19 22:24 ` [Bug fortran/40019] " fxcoudert at gcc dot gnu dot org
2009-05-27 7:45 ` burnus at gcc dot gnu dot org
2009-05-27 10:28 ` fxcoudert at gcc dot gnu dot org
2009-05-29 21:28 ` burnus at gcc dot gnu dot org
2009-05-29 21:34 ` burnus at gcc dot gnu dot org
2009-06-03 19:39 ` [Bug fortran/40019] [4.4 only] " burnus at gcc dot gnu dot org
2009-06-03 19:40 ` [Bug fortran/40019] " burnus at gcc dot gnu dot org
2009-06-03 19:56 ` 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).