public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/49642] New: constant part of a macro not optimized away as expected due to splitter
@ 2011-07-05 12:40 marcus at jet dot franken.de
  2011-07-05 12:41 ` [Bug c/49642] " marcus at jet dot franken.de
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: marcus at jet dot franken.de @ 2011-07-05 12:40 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: constant part of a macro not optimized away as
                    expected due to splitter
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: marcus@jet.franken.de


my Linux kernel builds on gcc 4.6 pcc64 fail with:

ERROR: ".____ilog2_NaN" [drivers/infiniband/hw/ehca/ib_ehca.ko] undefined!

This comes from include/linux/log2.h which uses a large macro with
builtin_constant_p() to optimize constant ilog2 calls.

I have reduced it to the attached testcase.

$ gcc -m64 -O2 -fno-inline-functions-called-once -c ehca_mrmw.i ; objdump -dr
ehca_mrmw.o |grep NaN
                        1a8: R_PPC64_REL24      ____ilog2_NaN
                        1cc: R_PPC64_REL24      ____ilog2_NaN
$ 

It should not report NaN as that is in a if
(__builtin_constant_p(shca->hca_cap_mr_pgsize)) expression.


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

* [Bug c/49642] constant part of a macro not optimized away as expected due to splitter
  2011-07-05 12:40 [Bug c/49642] New: constant part of a macro not optimized away as expected due to splitter marcus at jet dot franken.de
@ 2011-07-05 12:41 ` marcus at jet dot franken.de
  2011-07-05 12:43 ` marcus at jet dot franken.de
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: marcus at jet dot franken.de @ 2011-07-05 12:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from marcus at jet dot franken.de 2011-07-05 12:41:05 UTC ---
Created attachment 24690
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24690
ehca_mrmw.i

gcc -m64 -O2 -fno-inline-functions-called-once -c ehca_mrmw.i ; objdump -dr
ehca_mrmw.o |grep NaN

should not report:
                        1a8: R_PPC64_REL24      ____ilog2_NaN


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

* [Bug c/49642] constant part of a macro not optimized away as expected due to splitter
  2011-07-05 12:40 [Bug c/49642] New: constant part of a macro not optimized away as expected due to splitter marcus at jet dot franken.de
  2011-07-05 12:41 ` [Bug c/49642] " marcus at jet dot franken.de
@ 2011-07-05 12:43 ` marcus at jet dot franken.de
  2011-07-05 12:59 ` [Bug tree-optimization/49642] " rguenth at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: marcus at jet dot franken.de @ 2011-07-05 12:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from marcus at jet dot franken.de 2011-07-05 12:42:28 UTC ---
looking at the assembly, both x() and y() call the assembler functions,
just the static function is still emitted with
0000000000000000 <.ehca_get_max_hwpage_size.part.0>:

name. This instance could probably be safely deleted.


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

* [Bug tree-optimization/49642] constant part of a macro not optimized away as expected due to splitter
  2011-07-05 12:40 [Bug c/49642] New: constant part of a macro not optimized away as expected due to splitter marcus at jet dot franken.de
  2011-07-05 12:41 ` [Bug c/49642] " marcus at jet dot franken.de
  2011-07-05 12:43 ` marcus at jet dot franken.de
@ 2011-07-05 12:59 ` rguenth at gcc dot gnu.org
  2012-01-06 17:09 ` wschmidt at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-07-05 12:59 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.07.05 12:59:02
                 CC|                            |hubicka at gcc dot gnu.org
          Component|c                           |tree-optimization
            Version|tree-ssa                    |4.6.1
     Ever Confirmed|0                           |1

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-07-05 12:59:02 UTC ---
Confirmed.

Honza - we split a __builtin_constant_p guarded section away, not killing off
the not needed constant case as we process final optimizations in the wrong
order (thus we don't see the function is unused soon enough).

I think it isn't a good idea to split away any code dominated by such
call.  The testcase is basically

int foo(int arg)
{
 if (__builtin_constant_p (arg))
   {
     if (arg == 10)
       return 1;
     return unreachable ();
   }
 return arg;
}

and we split it as

int foo (int arg)
{
  if (__builtin_constant_p (arg))
    return foo.part (arg);
  return arg;
}


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

* [Bug tree-optimization/49642] constant part of a macro not optimized away as expected due to splitter
  2011-07-05 12:40 [Bug c/49642] New: constant part of a macro not optimized away as expected due to splitter marcus at jet dot franken.de
                   ` (2 preceding siblings ...)
  2011-07-05 12:59 ` [Bug tree-optimization/49642] " rguenth at gcc dot gnu.org
@ 2012-01-06 17:09 ` wschmidt at gcc dot gnu.org
  2012-01-07  0:13 ` wschmidt at gcc dot gnu.org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2012-01-06 17:09 UTC (permalink / raw)
  To: gcc-bugs

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

William J. Schmidt <wschmidt at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wschmidt at gcc dot gnu.org

--- Comment #4 from William J. Schmidt <wschmidt at gcc dot gnu.org> 2012-01-06 17:09:01 UTC ---
I noticed today that this bug does not reproduce on trunk, though it still does
on the 4_6 branch.  Does anyone know if this was intentionally fixed but
perhaps not backported into 4.6?


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

* [Bug tree-optimization/49642] constant part of a macro not optimized away as expected due to splitter
  2011-07-05 12:40 [Bug c/49642] New: constant part of a macro not optimized away as expected due to splitter marcus at jet dot franken.de
                   ` (3 preceding siblings ...)
  2012-01-06 17:09 ` wschmidt at gcc dot gnu.org
@ 2012-01-07  0:13 ` wschmidt at gcc dot gnu.org
  2012-01-09 12:11 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2012-01-07  0:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from William J. Schmidt <wschmidt at gcc dot gnu.org> 2012-01-07 00:13:10 UTC ---
This was "solved" (or became dormant) with revision 171450 on trunk:

2011-03-25  Richard Guenther  <rguenther@suse.de>

    * passes.c (init_optimization_passes): Add FRE pass after
    early SRA.


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

* [Bug tree-optimization/49642] constant part of a macro not optimized away as expected due to splitter
  2011-07-05 12:40 [Bug c/49642] New: constant part of a macro not optimized away as expected due to splitter marcus at jet dot franken.de
                   ` (4 preceding siblings ...)
  2012-01-07  0:13 ` wschmidt at gcc dot gnu.org
@ 2012-01-09 12:11 ` rguenth at gcc dot gnu.org
  2012-01-09 21:59 ` wschmidt at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-01-09 12:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #6 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-09 12:10:50 UTC ---
Fixed for 4.7.


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

* [Bug tree-optimization/49642] constant part of a macro not optimized away as expected due to splitter
  2011-07-05 12:40 [Bug c/49642] New: constant part of a macro not optimized away as expected due to splitter marcus at jet dot franken.de
                   ` (5 preceding siblings ...)
  2012-01-09 12:11 ` rguenth at gcc dot gnu.org
@ 2012-01-09 21:59 ` wschmidt at gcc dot gnu.org
  2012-01-11 16:52 ` wschmidt at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2012-01-09 21:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from William J. Schmidt <wschmidt at gcc dot gnu.org> 2012-01-09 21:57:57 UTC ---
I should note that the problem still persists in 4.7 when -fno-tree-fre is
specified.

For 4.6, I am working on a solution along the lines Richi outlined above.  We
may want to consider putting that in 4.7 as well for the -fno-tree-fre case.


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

* [Bug tree-optimization/49642] constant part of a macro not optimized away as expected due to splitter
  2011-07-05 12:40 [Bug c/49642] New: constant part of a macro not optimized away as expected due to splitter marcus at jet dot franken.de
                   ` (6 preceding siblings ...)
  2012-01-09 21:59 ` wschmidt at gcc dot gnu.org
@ 2012-01-11 16:52 ` wschmidt at gcc dot gnu.org
  2012-01-11 22:38 ` wschmidt at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2012-01-11 16:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from William J. Schmidt <wschmidt at gcc dot gnu.org> 2012-01-11 16:52:13 UTC ---
Author: wschmidt
Date: Wed Jan 11 16:52:03 2012
New Revision: 183101

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183101
Log:
gcc:

2012-01-11  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

    PR tree-optimization/49642
    * ipa-split.c (forbidden_dominators): New variable.
    (check_forbidden_calls): New function.
    (dominated_by_forbidden): Likewise.
    (consider_split): Check for forbidden dominators.
    (execute_split_functions): Initialize and free forbidden
    dominators info; call check_forbidden_calls.

gcc/testsuite:

2012-01-11  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

    PR tree-optimization/49642
    * gcc.dg/tree-ssa/pr49642-1.c: New test.
    * gcc.dg/tree-ssa/pr49642-2.c: New test.


Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/pr49642-1.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/pr49642-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ipa-split.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug tree-optimization/49642] constant part of a macro not optimized away as expected due to splitter
  2011-07-05 12:40 [Bug c/49642] New: constant part of a macro not optimized away as expected due to splitter marcus at jet dot franken.de
                   ` (7 preceding siblings ...)
  2012-01-11 16:52 ` wschmidt at gcc dot gnu.org
@ 2012-01-11 22:38 ` wschmidt at gcc dot gnu.org
  2012-01-18 20:07 ` wschmidt at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2012-01-11 22:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from William J. Schmidt <wschmidt at gcc dot gnu.org> 2012-01-11 22:37:33 UTC ---
Author: wschmidt
Date: Wed Jan 11 22:37:26 2012
New Revision: 183110

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183110
Log:
gcc:

2012-01-11  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

    PR tree-optimization/49642
    * ipa-split.c (forbidden_dominators): New variable.
    (check_forbidden_calls): New function.
    (dominated_by_forbidden): Likewise.
    (consider_split): Check for forbidden dominators.
    (execute_split_functions): Initialize and free forbidden
    dominators info; call check_forbidden_calls.

gcc/testsuite:

2012-01-11  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

    PR tree-optimization/49642
    * gcc.dg/tree-ssa/pr49642.c: New test.


Added:
    branches/ibm/gcc-4_6-branch/gcc/testsuite/gcc.dg/tree-ssa/pr49642.c
Modified:
    branches/ibm/gcc-4_6-branch/gcc/ChangeLog.ibm
    branches/ibm/gcc-4_6-branch/gcc/ipa-split.c
    branches/ibm/gcc-4_6-branch/gcc/testsuite/ChangeLog.ibm


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

* [Bug tree-optimization/49642] constant part of a macro not optimized away as expected due to splitter
  2011-07-05 12:40 [Bug c/49642] New: constant part of a macro not optimized away as expected due to splitter marcus at jet dot franken.de
                   ` (8 preceding siblings ...)
  2012-01-11 22:38 ` wschmidt at gcc dot gnu.org
@ 2012-01-18 20:07 ` wschmidt at gcc dot gnu.org
  2012-01-18 20:37 ` wschmidt at gcc dot gnu.org
  2012-01-18 23:06 ` ebotcazou at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2012-01-18 20:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from William J. Schmidt <wschmidt at gcc dot gnu.org> 2012-01-18 19:28:23 UTC ---
Author: wschmidt
Date: Wed Jan 18 19:28:19 2012
New Revision: 183284

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183284
Log:
gcc:

2012-01-11  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

    PR tree-optimization/49642
    * ipa-split.c (forbidden_dominators): New variable.
    (check_forbidden_calls): New function.
    (dominated_by_forbidden): Likewise.
    (consider_split): Check for forbidden dominators.
    (execute_split_functions): Initialize and free forbidden
    dominators info; call check_forbidden_calls.

gcc/testsuite:

2012-01-11  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

    PR tree-optimization/49642
    * gcc.dg/tree-ssa/pr49642.c: New test.


Added:
    branches/gcc-4_6-branch/gcc/testsuite/gcc.dg/tree-ssa/pr49642.c
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/ipa-split.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


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

* [Bug tree-optimization/49642] constant part of a macro not optimized away as expected due to splitter
  2011-07-05 12:40 [Bug c/49642] New: constant part of a macro not optimized away as expected due to splitter marcus at jet dot franken.de
                   ` (9 preceding siblings ...)
  2012-01-18 20:07 ` wschmidt at gcc dot gnu.org
@ 2012-01-18 20:37 ` wschmidt at gcc dot gnu.org
  2012-01-18 23:06 ` ebotcazou at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2012-01-18 20:37 UTC (permalink / raw)
  To: gcc-bugs

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

William J. Schmidt <wschmidt at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |CLOSED

--- Comment #11 from William J. Schmidt <wschmidt at gcc dot gnu.org> 2012-01-18 20:21:04 UTC ---
Fixed in 4.7, 4.6, ibm/4.6 = AT5.0.


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

* [Bug tree-optimization/49642] constant part of a macro not optimized away as expected due to splitter
  2011-07-05 12:40 [Bug c/49642] New: constant part of a macro not optimized away as expected due to splitter marcus at jet dot franken.de
                   ` (10 preceding siblings ...)
  2012-01-18 20:37 ` wschmidt at gcc dot gnu.org
@ 2012-01-18 23:06 ` ebotcazou at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-01-18 23:06 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|CLOSED                      |RESOLVED
                 CC|                            |ebotcazou at gcc dot
                   |                            |gnu.org


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

end of thread, other threads:[~2012-01-18 21:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-05 12:40 [Bug c/49642] New: constant part of a macro not optimized away as expected due to splitter marcus at jet dot franken.de
2011-07-05 12:41 ` [Bug c/49642] " marcus at jet dot franken.de
2011-07-05 12:43 ` marcus at jet dot franken.de
2011-07-05 12:59 ` [Bug tree-optimization/49642] " rguenth at gcc dot gnu.org
2012-01-06 17:09 ` wschmidt at gcc dot gnu.org
2012-01-07  0:13 ` wschmidt at gcc dot gnu.org
2012-01-09 12:11 ` rguenth at gcc dot gnu.org
2012-01-09 21:59 ` wschmidt at gcc dot gnu.org
2012-01-11 16:52 ` wschmidt at gcc dot gnu.org
2012-01-11 22:38 ` wschmidt at gcc dot gnu.org
2012-01-18 20:07 ` wschmidt at gcc dot gnu.org
2012-01-18 20:37 ` wschmidt at gcc dot gnu.org
2012-01-18 23:06 ` ebotcazou 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).