public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/15347] New: [tree-ssa] fold if ("<12ers" + 1 == 0).
@ 2004-05-09 19:25 kazu at cs dot umass dot edu
  2004-05-09 19:41 ` [Bug optimization/15347] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-05-09 19:25 UTC (permalink / raw)
  To: gcc-bugs

void bar ();

int
foo (void)
{
  if ("<12ers" + 1 == 0)
    bar ();
}

which is reduced from from

extern const char tree_code_type[];

extern char *strchr (__const char *__s, int __c) __attribute__ ((__pure__));

extern void abort (void) __attribute__ ((__noreturn__));

int
foo (int a)
{
  if (tree_code_type[a] == '1')
    if (strchr ("<12ers", tree_code_type[a]) == 0)
      abort ();
}

which is in turn reduced from find_base_decl() in alias.c.

-- 
           Summary: [tree-ssa] fold if ("<12ers" + 1 == 0).
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Keywords: pessimizes-code
          Severity: normal
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kazu at cs dot umass dot edu
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15347


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug optimization/15347] [tree-ssa] fold if ("<12ers" + 1 == 0).
  2004-05-09 19:25 [Bug optimization/15347] New: [tree-ssa] fold if ("<12ers" + 1 == 0) kazu at cs dot umass dot edu
@ 2004-05-09 19:41 ` pinskia at gcc dot gnu dot org
  2004-05-09 20:15 ` kazu at cs dot umass dot edu
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-09 19:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-09 19:41 -------
I think the two test cases are not related at all, the second one only needs to fold strchr ("<12ers", '1' ) 
to 1 (which it does when expanding to RTL).  There are two problems with the first testcase, first 
"<12ers" + 1 == 0 is "folded" to "<12ers" == -1 by fold, and but if you add a tempary variable then "< 
12ers" + 1 == 0 is not folded to false.  Confirmed otherwise, the orginal testcase is not done on the 
RTL level but the other two are.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |TREE
   Last reconfirmed|0000-00-00 00:00:00         |2004-05-09 19:41:05
               date|                            |
   Target Milestone|---                         |tree-ssa


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15347


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug optimization/15347] [tree-ssa] fold if ("<12ers" + 1 == 0).
  2004-05-09 19:25 [Bug optimization/15347] New: [tree-ssa] fold if ("<12ers" + 1 == 0) kazu at cs dot umass dot edu
  2004-05-09 19:41 ` [Bug optimization/15347] " pinskia at gcc dot gnu dot org
@ 2004-05-09 20:15 ` kazu at cs dot umass dot edu
  2004-05-09 20:22 ` kazu at cs dot umass dot edu
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-05-09 20:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kazu at cs dot umass dot edu  2004-05-09 20:15 -------
Andrew, I forgot to say that the first testcase can be obtained more or less
if you use Steven's strchr optimization patch.
IIRC, His strchr optimization happens in CCP, so
fold does not get to fold "<12ers" + 1 == 0 into false.

In any case, all the stupidity in this area should go away.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15347


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug optimization/15347] [tree-ssa] fold if ("<12ers" + 1 == 0).
  2004-05-09 19:25 [Bug optimization/15347] New: [tree-ssa] fold if ("<12ers" + 1 == 0) kazu at cs dot umass dot edu
  2004-05-09 19:41 ` [Bug optimization/15347] " pinskia at gcc dot gnu dot org
  2004-05-09 20:15 ` kazu at cs dot umass dot edu
@ 2004-05-09 20:22 ` kazu at cs dot umass dot edu
  2004-05-24 22:29 ` [Bug tree-optimization/15347] " pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-05-09 20:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kazu at cs dot umass dot edu  2004-05-09 20:22 -------
See also PR 14819.
If strchr() is folded to NULL, we don't have to worry about anything.
Otherwise, resolution of this PR is important.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15347


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug tree-optimization/15347] [tree-ssa] fold if ("<12ers" + 1 == 0).
  2004-05-09 19:25 [Bug optimization/15347] New: [tree-ssa] fold if ("<12ers" + 1 == 0) kazu at cs dot umass dot edu
                   ` (2 preceding siblings ...)
  2004-05-09 20:22 ` kazu at cs dot umass dot edu
@ 2004-05-24 22:29 ` pinskia at gcc dot gnu dot org
  2004-06-01  6:45 ` kazu at cs dot umass dot edu
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-24 22:29 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.5.0                       |---


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15347


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug tree-optimization/15347] [tree-ssa] fold if ("<12ers" + 1 == 0).
  2004-05-09 19:25 [Bug optimization/15347] New: [tree-ssa] fold if ("<12ers" + 1 == 0) kazu at cs dot umass dot edu
                   ` (3 preceding siblings ...)
  2004-05-24 22:29 ` [Bug tree-optimization/15347] " pinskia at gcc dot gnu dot org
@ 2004-06-01  6:45 ` kazu at cs dot umass dot edu
  2004-06-01  6:48 ` kazu at cs dot umass dot edu
  2004-06-03 23:22 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 16+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-06-01  6:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kazu at cs dot umass dot edu  2004-06-01 06:45 -------
Now that Steven's strchr patch is in, let me reiterate the problem.

void bar (void);

void
foo (void)
{
  int c = '1';

  if (strchr ("<12ers", c) == 0)
    bar ();
}

void
baz (void)
{
  int c = '1';

  if ("<12ers" + 1 == 0)
    bar ();
}

The last tree-ssa form looks like:

;; Function foo (foo)

foo ()
{
  int c;
  char * T.0;

<bb 0>:
  T.0_2 = "<12ers" + 1B;
  if (T.0_2 == 0B) goto <L0>; else goto <L1>;

<L0>:;
  bar () [tail call];

<L1>:;
  return;

}



;; Function baz (baz)

baz ()
{
  int c;

<bb 0>:
  if ("<12ers" == -1B) goto <L0>; else goto <L1>;

<L0>:;
  bar () [tail call];

<L1>:;
  return;

}

In either case, we miss the folding opportunity.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15347


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug tree-optimization/15347] [tree-ssa] fold if ("<12ers" + 1 == 0).
  2004-05-09 19:25 [Bug optimization/15347] New: [tree-ssa] fold if ("<12ers" + 1 == 0) kazu at cs dot umass dot edu
                   ` (4 preceding siblings ...)
  2004-06-01  6:45 ` kazu at cs dot umass dot edu
@ 2004-06-01  6:48 ` kazu at cs dot umass dot edu
  2004-06-03 23:22 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 16+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-06-01  6:48 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From kazu at cs dot umass dot edu  2004-06-01 06:47 -------
"int c = '1';" in baz() in comment #4 is an unintended garbage.
Please ignore it.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15347


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug tree-optimization/15347] [tree-ssa] fold if ("<12ers" + 1 == 0).
  2004-05-09 19:25 [Bug optimization/15347] New: [tree-ssa] fold if ("<12ers" + 1 == 0) kazu at cs dot umass dot edu
                   ` (5 preceding siblings ...)
  2004-06-01  6:48 ` kazu at cs dot umass dot edu
@ 2004-06-03 23:22 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-03 23:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-03 23:22 -------
I should note that "12ers" == 0 is folded to false by:
      /* If this is an equality comparison of the address of a non-weak
         object against zero, then we know the result.  */

So improving that part will help.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15347


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug tree-optimization/15347] [tree-ssa] fold if ("<12ers" + 1 == 0).
       [not found] <bug-15347-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2011-04-28 10:05 ` rguenth at gcc dot gnu.org
@ 2014-10-31  4:02 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-10-31  4:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=15347
Bug 15347 depends on bug 15459, which changed state.

Bug 15459 Summary: [meta-bug] there should be a tree combiner like the rtl one
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=15459

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug tree-optimization/15347] [tree-ssa] fold if ("<12ers" + 1 == 0).
       [not found] <bug-15347-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2011-04-28 10:02 ` rguenth at gcc dot gnu.org
@ 2011-04-28 10:05 ` rguenth at gcc dot gnu.org
  2014-10-31  4:02 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-28 10:05 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15347

--- Comment #11 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-04-28 09:55:46 UTC ---
Author: rguenth
Date: Thu Apr 28 09:55:41 2011
New Revision: 173064

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173064
Log:
2011-04-28  Richard Guenther  <rguenther@suse.de>

    PR tree-optimization/40052
    PR tree-optimization/15347
    * gcc.dg/tree-ssa/vrp57.c: New testcase.
    * gcc.dg/pr15347.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.dg/pr15347.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/vrp57.c
Modified:
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug tree-optimization/15347] [tree-ssa] fold if ("<12ers" + 1 == 0).
       [not found] <bug-15347-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2011-04-28  9:59 ` rguenth at gcc dot gnu.org
@ 2011-04-28 10:02 ` rguenth at gcc dot gnu.org
  2011-04-28 10:05 ` rguenth at gcc dot gnu.org
  2014-10-31  4:02 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-28 10:02 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15347

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.6.0

--- Comment #12 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-04-28 09:56:52 UTC ---
Fixed.  Thanks for noticing.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug tree-optimization/15347] [tree-ssa] fold if ("<12ers" + 1 == 0).
       [not found] <bug-15347-4@http.gcc.gnu.org/bugzilla/>
  2011-04-27 17:54 ` matt at use dot net
  2011-04-27 18:32 ` hjl.tools at gmail dot com
@ 2011-04-28  9:59 ` rguenth at gcc dot gnu.org
  2011-04-28 10:02 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-28  9:59 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15347

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #13 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-04-28 09:57:05 UTC ---
Fi-xed.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug tree-optimization/15347] [tree-ssa] fold if ("<12ers" + 1 == 0).
       [not found] <bug-15347-4@http.gcc.gnu.org/bugzilla/>
  2011-04-27 17:54 ` matt at use dot net
@ 2011-04-27 18:32 ` hjl.tools at gmail dot com
  2011-04-28  9:59 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 16+ messages in thread
From: hjl.tools at gmail dot com @ 2011-04-27 18:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15347

--- Comment #10 from H.J. Lu <hjl.tools at gmail dot com> 2011-04-27 18:32:34 UTC ---
(In reply to comment #9)
> This appears to be fixed in 4.6.0. Mark as resolved?

Need to add a few testcases first.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug tree-optimization/15347] [tree-ssa] fold if ("<12ers" + 1 == 0).
       [not found] <bug-15347-4@http.gcc.gnu.org/bugzilla/>
@ 2011-04-27 17:54 ` matt at use dot net
  2011-04-27 18:32 ` hjl.tools at gmail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 16+ messages in thread
From: matt at use dot net @ 2011-04-27 17:54 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15347

Matt Hargett <matt at use dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |matt at use dot net

--- Comment #9 from Matt Hargett <matt at use dot net> 2011-04-27 17:52:06 UTC ---
This appears to be fixed in 4.6.0. Mark as resolved?


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug tree-optimization/15347] [tree-ssa] fold if ("<12ers" + 1 == 0).
       [not found] <bug-15347-5009@http.gcc.gnu.org/bugzilla/>
  2005-12-07  3:23 ` pinskia at gcc dot gnu dot org
@ 2006-09-17  8:44 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-09-17  8:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pinskia at gcc dot gnu dot org  2006-09-17 08:44 -------
Just to clarify what testcase is still broken, here it is:
void baz (void)
{
  if ("<12ers" + 1 == 0)
    bar ();
}

------
The reason why strchr testcase is fixed is because we turn the strchr call into
&"<12ers"[1].


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
   Last reconfirmed|2006-03-01 02:45:29         |2006-09-17 08:44:52
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15347


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Bug tree-optimization/15347] [tree-ssa] fold if ("<12ers" + 1 == 0).
       [not found] <bug-15347-5009@http.gcc.gnu.org/bugzilla/>
@ 2005-12-07  3:23 ` pinskia at gcc dot gnu dot org
  2006-09-17  8:44 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-12-07  3:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2005-12-07 03:23 -------
I should note that the first testcase in comment #0 in the bug is fixed but not
the second, non reduced one.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2005-09-07 18:50:42         |2005-12-07 03:23:13
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15347


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2014-10-31  4:02 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-09 19:25 [Bug optimization/15347] New: [tree-ssa] fold if ("<12ers" + 1 == 0) kazu at cs dot umass dot edu
2004-05-09 19:41 ` [Bug optimization/15347] " pinskia at gcc dot gnu dot org
2004-05-09 20:15 ` kazu at cs dot umass dot edu
2004-05-09 20:22 ` kazu at cs dot umass dot edu
2004-05-24 22:29 ` [Bug tree-optimization/15347] " pinskia at gcc dot gnu dot org
2004-06-01  6:45 ` kazu at cs dot umass dot edu
2004-06-01  6:48 ` kazu at cs dot umass dot edu
2004-06-03 23:22 ` pinskia at gcc dot gnu dot org
     [not found] <bug-15347-5009@http.gcc.gnu.org/bugzilla/>
2005-12-07  3:23 ` pinskia at gcc dot gnu dot org
2006-09-17  8:44 ` pinskia at gcc dot gnu dot org
     [not found] <bug-15347-4@http.gcc.gnu.org/bugzilla/>
2011-04-27 17:54 ` matt at use dot net
2011-04-27 18:32 ` hjl.tools at gmail dot com
2011-04-28  9:59 ` rguenth at gcc dot gnu.org
2011-04-28 10:02 ` rguenth at gcc dot gnu.org
2011-04-28 10:05 ` rguenth at gcc dot gnu.org
2014-10-31  4:02 ` pinskia at gcc dot gnu.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).