public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/23522] [3.4/4.0/4.1 Regression] fold_widened_comparison bug
[not found] <bug-23522-7321@http.gcc.gnu.org/bugzilla/>
@ 2005-10-18 3:16 ` cvs-commit at gcc dot gnu dot org
2005-10-18 3:19 ` cvs-commit at gcc dot gnu dot org
2005-10-18 3:20 ` ian at airs dot com
2 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-10-18 3:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from cvs-commit at gcc dot gnu dot org 2005-10-18 03:16 -------
Subject: Bug 23522
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: ian@gcc.gnu.org 2005-10-18 03:16:21
Modified files:
gcc : ChangeLog fold-const.c
Log message:
PR middle-end/23522
* fold-const.c (fold_widened_comparison): Do not allow range based
constant folding when right operand cannot be unwidened.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.10178&r2=2.10179
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&r1=1.627&r2=1.628
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23522
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/23522] [3.4/4.0/4.1 Regression] fold_widened_comparison bug
[not found] <bug-23522-7321@http.gcc.gnu.org/bugzilla/>
2005-10-18 3:16 ` [Bug middle-end/23522] [3.4/4.0/4.1 Regression] fold_widened_comparison bug cvs-commit at gcc dot gnu dot org
@ 2005-10-18 3:19 ` cvs-commit at gcc dot gnu dot org
2005-10-18 3:20 ` ian at airs dot com
2 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-10-18 3:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from cvs-commit at gcc dot gnu dot org 2005-10-18 03:19 -------
Subject: Bug 23522
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-4_0-branch
Changes by: ian@gcc.gnu.org 2005-10-18 03:19:14
Modified files:
gcc : ChangeLog fold-const.c
Log message:
PR middle-end/23522
* fold-const.c (fold_widened_comparison): Do not allow range based
constant folding when right operand cannot be unwidened.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.468&r2=2.7592.2.469
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.517.2.16&r2=1.517.2.17
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23522
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/23522] [3.4/4.0/4.1 Regression] fold_widened_comparison bug
[not found] <bug-23522-7321@http.gcc.gnu.org/bugzilla/>
2005-10-18 3:16 ` [Bug middle-end/23522] [3.4/4.0/4.1 Regression] fold_widened_comparison bug cvs-commit at gcc dot gnu dot org
2005-10-18 3:19 ` cvs-commit at gcc dot gnu dot org
@ 2005-10-18 3:20 ` ian at airs dot com
2 siblings, 0 replies; 7+ messages in thread
From: ian at airs dot com @ 2005-10-18 3:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from ian at airs dot com 2005-10-18 03:20 -------
Fixed on mainline and 4.0 branch.
--
ian at airs dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23522
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/23522] [3.4/4.0/4.1 Regression] fold_widened_comparison bug
2005-08-23 1:20 [Bug tree-optimization/23522] New: fold() bug alexey dot starovoytov at sun dot com
` (2 preceding siblings ...)
2005-09-07 9:26 ` rguenth at gcc dot gnu dot org
@ 2005-09-27 15:57 ` mmitchel at gcc dot gnu dot org
3 siblings, 0 replies; 7+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-09-27 15:57 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.0.2 |4.0.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23522
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/23522] [3.4/4.0/4.1 Regression] fold_widened_comparison bug
2005-08-23 1:20 [Bug tree-optimization/23522] New: fold() bug alexey dot starovoytov at sun dot com
2005-08-23 1:47 ` [Bug middle-end/23522] [3.4/4.0/4.1 Regression] fold_widened_comparison bug pinskia at gcc dot gnu dot org
2005-08-23 23:47 ` alexey dot starovoytov at sun dot com
@ 2005-09-07 9:26 ` rguenth at gcc dot gnu dot org
2005-09-27 15:57 ` mmitchel at gcc dot gnu dot org
3 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-09-07 9:26 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rguenth at gcc dot gnu dot org 2005-09-07 09:26 -------
I agree with the analysis and the fix. Care to submit the patch to gcc-patches?
Do you have a copyright assignment on file with the FSF? If not the patch may
be simple enough to be accepted regardless of this.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23522
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/23522] [3.4/4.0/4.1 Regression] fold_widened_comparison bug
2005-08-23 1:20 [Bug tree-optimization/23522] New: fold() bug alexey dot starovoytov at sun dot com
2005-08-23 1:47 ` [Bug middle-end/23522] [3.4/4.0/4.1 Regression] fold_widened_comparison bug pinskia at gcc dot gnu dot org
@ 2005-08-23 23:47 ` alexey dot starovoytov at sun dot com
2005-09-07 9:26 ` rguenth at gcc dot gnu dot org
2005-09-27 15:57 ` mmitchel at gcc dot gnu dot org
3 siblings, 0 replies; 7+ messages in thread
From: alexey dot starovoytov at sun dot com @ 2005-08-23 23:47 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From alexey dot starovoytov at sun dot com 2005-08-23 23:35 -------
Actually I think 3.x versions are fine.
Here is the snipper from 3.4.3:
else if (TREE_CODE (TREE_TYPE (arg0)) == INTEGER_TYPE
&& TREE_CODE (arg0) == NOP_EXPR
&& (tem = get_unwidened (arg0, NULL_TREE)) != arg0
&& (code == EQ_EXPR || code == NE_EXPR
|| TREE_UNSIGNED (TREE_TYPE (arg0))
== TREE_UNSIGNED (TREE_TYPE (tem)))
&& (t1 = get_unwidened (arg1, TREE_TYPE (tem))) != 0
&& (TREE_TYPE (t1) == TREE_TYPE (tem)
|| (TREE_CODE (t1) == INTEGER_CST
&& int_fits_type_p (t1, TREE_TYPE (tem)))))
return fold (build (code, type, tem,
fold_convert (TREE_TYPE (tem), t1)));
the (t1 = get_unwidened (arg1, TREE_TYPE (tem))) != 0 line
may look suspicious, but it's actually just redundant.
If it's changed to t1 != arg1, then probably int_fits_type_p() condition
will never be called.
The real problem is in 4.0 and 4.1.
The snipper from 4.0.1:
if (TREE_CODE (arg1_unw) != INTEGER_CST)
return NULL_TREE;
/* If we are comparing with the integer that does not fit into the range
of the shorter type, the result is known. */
outer_type = TREE_TYPE (arg1_unw);
min = lower_bound_in_type (outer_type, shorter_type);
max = upper_bound_in_type (outer_type, shorter_type);
above = integer_nonzerop (fold_relational_const (LT_EXPR, type,
max, arg1_unw));
below = integer_nonzerop (fold_relational_const (LT_EXPR, type,
arg1_unw, min));
switch (code)
{
case EQ_EXPR:
if (above || below)
return omit_one_operand (type, integer_zero_node, arg0);
break;
This optimization is incorrect if unwidening of arg1 didn't happen.
So I think the proper new fix would be to remove lines 6104,6105
and add the check that unwidening happened to line 6115:
------- fold-const.c -------
*** /tmp/geta16407 Tue Aug 23 16:21:18 2005
--- /tmp/getb16407 Tue Aug 23 16:21:18 2005
***************
*** 6101,6108 ****
return NULL_TREE;
arg1_unw = get_unwidened (arg1, shorter_type);
- if (!arg1_unw)
- return NULL_TREE;
/* If possible, express the comparison in the shorter mode. */
if ((code == EQ_EXPR || code == NE_EXPR
--- 6101,6106 ----
***************
*** 6114,6120 ****
return fold (build (code, type, arg0_unw,
fold_convert (shorter_type, arg1_unw)));
! if (TREE_CODE (arg1_unw) != INTEGER_CST)
return NULL_TREE;
/* If we are comparing with the integer that does not fit into the range
--- 6112,6118 ----
return fold (build (code, type, arg0_unw,
fold_convert (shorter_type, arg1_unw)));
! if (arg1_unw == arg1 || TREE_CODE (arg1_unw) != INTEGER_CST)
return NULL_TREE;
/* If we are comparing with the integer that does not fit into the range
My previous suggested fix accidentally disabled vectorization in
gcc.dg/vect/vect-87.c and gcc.dg/vect/vect-88.c on 64-bit targets.
New fix seems to be fine.
Alex.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23522
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug middle-end/23522] [3.4/4.0/4.1 Regression] fold_widened_comparison bug
2005-08-23 1:20 [Bug tree-optimization/23522] New: fold() bug alexey dot starovoytov at sun dot com
@ 2005-08-23 1:47 ` pinskia at gcc dot gnu dot org
2005-08-23 23:47 ` alexey dot starovoytov at sun dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-23 1:47 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-08-23 01:41 -------
Broken before fold_widended_comparison was added:
&& (t1 = get_unwidened (arg1, TREE_TYPE (tem))) != 0
So this is a regression from 2.95.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |wrong-code
Known to fail| |4.0.0 4.1.0 3.4.0 3.0.4
| |3.3.3
Known to work| |2.95
Last reconfirmed|0000-00-00 00:00:00 |2005-08-23 01:41:50
date| |
Summary|fold_widened_comparison bug |[3.4/4.0/4.1 Regression]
| |fold_widened_comparison bug
Target Milestone|--- |4.0.2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23522
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-10-18 3:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-23522-7321@http.gcc.gnu.org/bugzilla/>
2005-10-18 3:16 ` [Bug middle-end/23522] [3.4/4.0/4.1 Regression] fold_widened_comparison bug cvs-commit at gcc dot gnu dot org
2005-10-18 3:19 ` cvs-commit at gcc dot gnu dot org
2005-10-18 3:20 ` ian at airs dot com
2005-08-23 1:20 [Bug tree-optimization/23522] New: fold() bug alexey dot starovoytov at sun dot com
2005-08-23 1:47 ` [Bug middle-end/23522] [3.4/4.0/4.1 Regression] fold_widened_comparison bug pinskia at gcc dot gnu dot org
2005-08-23 23:47 ` alexey dot starovoytov at sun dot com
2005-09-07 9:26 ` rguenth at gcc dot gnu dot org
2005-09-27 15:57 ` mmitchel 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).