* [Bug c/16790] Integer down cast ignored in larger expression
2004-07-27 22:35 [Bug c/16790] New: Integer down cast ignored in larger expression andyb at mathworks dot com
@ 2004-07-27 22:42 ` andyb at mathworks dot com
2004-07-27 23:03 ` pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: andyb at mathworks dot com @ 2004-07-27 22:42 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From andyb at mathworks dot com 2004-07-27 22:42 -------
Created an attachment (id=6842)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6842&action=view)
preprocessor output .i file
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16790
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/16790] Integer down cast ignored in larger expression
2004-07-27 22:35 [Bug c/16790] New: Integer down cast ignored in larger expression andyb at mathworks dot com
2004-07-27 22:42 ` [Bug c/16790] " andyb at mathworks dot com
@ 2004-07-27 23:03 ` pinskia at gcc dot gnu dot org
2004-07-27 23:12 ` [Bug c/16790] [3.3/3.4/3.5 regression] " bangerth at dealii dot org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-27 23:03 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-07-27 23:03 -------
Note 0x8000 is out of range for 16bit ints.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16790
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/16790] [3.3/3.4/3.5 regression] Integer down cast ignored in larger expression
2004-07-27 22:35 [Bug c/16790] New: Integer down cast ignored in larger expression andyb at mathworks dot com
2004-07-27 22:42 ` [Bug c/16790] " andyb at mathworks dot com
2004-07-27 23:03 ` pinskia at gcc dot gnu dot org
@ 2004-07-27 23:12 ` bangerth at dealii dot org
2004-07-27 23:39 ` [Bug middle-end/16790] " pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: bangerth at dealii dot org @ 2004-07-27 23:12 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-07-27 23:12 -------
Confirmed. A regression in 3.3/3.4/mainline against 2.95. Here's
a reduced testcase:
----------------
void abort ();
static void compute(unsigned int u1)
{
unsigned char same_result;
signed short y_final_1;
signed short y_middle;
signed short y_final_2;
y_final_1 = (signed short)( (signed short)(u1 << 1) * 3 >> 1);
y_middle = (signed short)(u1 << 1);
y_final_2 = (signed short)( y_middle * 3 >> 1);
if (y_final_1 != y_final_2)
abort ();
}
main()
{
compute(0x4000U);
}
-----------------------------
Note that (0x4000<<1) is just the corner case when casted to signed int,
since it has only the sign bit set, none of the other bits are set. We
seem to get this wrong somehow.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Known to fail| |3.2.3 3.3.3 3.4.0 3.5.0
Known to work| |2.95
Last reconfirmed|0000-00-00 00:00:00 |2004-07-27 23:12:21
date| |
Summary|Integer down cast ignored in|[3.3/3.4/3.5 regression]
|larger expression |Integer down cast ignored in
| |larger expression
Target Milestone|--- |3.3.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16790
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/16790] [3.3/3.4/3.5 regression] Integer down cast ignored in larger expression
2004-07-27 22:35 [Bug c/16790] New: Integer down cast ignored in larger expression andyb at mathworks dot com
` (2 preceding siblings ...)
2004-07-27 23:12 ` [Bug c/16790] [3.3/3.4/3.5 regression] " bangerth at dealii dot org
@ 2004-07-27 23:39 ` pinskia at gcc dot gnu dot org
2004-08-03 21:24 ` cvs-commit at gcc dot gnu dot org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-27 23:39 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-07-27 23:39 -------
To say what happens is this (u1 * 2 is the same as u1 << 1:
(((int) (signed short)(u1 * 2)) * 3)
is being changed by fold (or in the C front-end) into
u1 * 6
most likely because there is a STRIP_NOP or (int)(short)(int_variable) is being changed into int_variable.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |gdr at gcc dot gnu dot org
Component|c |middle-end
Keywords| |wrong-code
Target Milestone|3.3.5 |3.4.2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16790
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/16790] [3.3/3.4/3.5 regression] Integer down cast ignored in larger expression
2004-07-27 22:35 [Bug c/16790] New: Integer down cast ignored in larger expression andyb at mathworks dot com
` (3 preceding siblings ...)
2004-07-27 23:39 ` [Bug middle-end/16790] " pinskia at gcc dot gnu dot org
@ 2004-08-03 21:24 ` cvs-commit at gcc dot gnu dot org
2004-08-07 21:57 ` [Bug middle-end/16790] [3.3/3.4 " cvs-commit at gcc dot gnu dot org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-08-03 21:24 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-08-03 21:24 -------
Subject: Bug 16790
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: sayle@gcc.gnu.org 2004-08-03 21:24:32
Modified files:
gcc : ChangeLog fold-const.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/gcc.c-torture/execute: pr16790-1.c
Log message:
PR middle-end/16790
* fold-const.c (extract_muldiv_1) <NOP_EXPR>: Disallow local
truncations, not just global truncations.
* gcc.c-torture/execute/pr16790-1.c: New test case.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.4785&r2=2.4786
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&r1=1.432&r2=1.433
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4090&r2=1.4091
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/pr16790-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16790
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/16790] [3.3/3.4 regression] Integer down cast ignored in larger expression
2004-07-27 22:35 [Bug c/16790] New: Integer down cast ignored in larger expression andyb at mathworks dot com
` (4 preceding siblings ...)
2004-08-03 21:24 ` cvs-commit at gcc dot gnu dot org
@ 2004-08-07 21:57 ` cvs-commit at gcc dot gnu dot org
2004-08-07 22:03 ` [Bug middle-end/16790] [3.3 " pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-08-07 21:57 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-08-07 21:56 -------
Subject: Bug 16790
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-3_4-branch
Changes by: sayle@gcc.gnu.org 2004-08-07 21:56:55
Modified files:
gcc : ChangeLog fold-const.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/gcc.c-torture/execute: pr16790-1.c
Log message:
PR middle-end/16790
Backport from mainline.
* fold-const.c (expand_muldiv_1) <NOP_EXPR>: Disallow local
truncations, not just global truncations.
* gcc.c-torture/execute/pr16790-1.c: New test case.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.575&r2=2.2326.2.576
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.322.2.12&r2=1.322.2.13
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.242&r2=1.3389.2.243
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/pr16790-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.4.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16790
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/16790] [3.3 regression] Integer down cast ignored in larger expression
2004-07-27 22:35 [Bug c/16790] New: Integer down cast ignored in larger expression andyb at mathworks dot com
` (5 preceding siblings ...)
2004-08-07 21:57 ` [Bug middle-end/16790] [3.3/3.4 " cvs-commit at gcc dot gnu dot org
@ 2004-08-07 22:03 ` pinskia at gcc dot gnu dot org
2004-08-08 18:55 ` cvs-commit at gcc dot gnu dot org
2004-08-08 18:57 ` pinskia at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-07 22:03 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-08-07 22:03 -------
Fixed also in 3.4.2.
--
What |Removed |Added
----------------------------------------------------------------------------
Known to work|2.95 3.5.0 |2.95 3.5.0 3.4.2
Summary|[3.3/3.4 regression] Integer|[3.3 regression] Integer
|down cast ignored in larger |down cast ignored in larger
|expression |expression
Target Milestone|3.4.2 |3.3.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16790
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/16790] [3.3 regression] Integer down cast ignored in larger expression
2004-07-27 22:35 [Bug c/16790] New: Integer down cast ignored in larger expression andyb at mathworks dot com
` (6 preceding siblings ...)
2004-08-07 22:03 ` [Bug middle-end/16790] [3.3 " pinskia at gcc dot gnu dot org
@ 2004-08-08 18:55 ` cvs-commit at gcc dot gnu dot org
2004-08-08 18:57 ` pinskia at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-08-08 18:55 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-08-08 18:55 -------
Subject: Bug 16790
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-3_3-branch
Changes by: sayle@gcc.gnu.org 2004-08-08 18:55:35
Modified files:
gcc : ChangeLog fold-const.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/gcc.c-torture/execute: pr16790-1.c
Log message:
2004-08-08 Roger Sayle <roger@eyesopen.com>
PR middle-end/16790
Backport from mainline.
* fold-const.c (expand_muldiv_1) <NOP_EXPR>: Disallow local
truncations, not just global truncations.
* gcc.c-torture/execute/pr16790-1.c: New test case.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.1009&r2=1.16114.2.1010
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.227.2.7&r2=1.227.2.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.382&r2=1.2261.2.383
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/pr16790-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.6.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16790
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug middle-end/16790] [3.3 regression] Integer down cast ignored in larger expression
2004-07-27 22:35 [Bug c/16790] New: Integer down cast ignored in larger expression andyb at mathworks dot com
` (7 preceding siblings ...)
2004-08-08 18:55 ` cvs-commit at gcc dot gnu dot org
@ 2004-08-08 18:57 ` pinskia at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-08 18:57 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-08-08 18:57 -------
Fixed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16790
^ permalink raw reply [flat|nested] 10+ messages in thread