public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/22051] New: [4.0 regression] Wrong code for function pointer comparision during optimization
@ 2005-06-13 16:14 tausq at debian dot org
  2005-06-13 16:16 ` [Bug tree-optimization/22051] [4.0 regression/hppa-linux] " tausq at debian dot org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: tausq at debian dot org @ 2005-06-13 16:14 UTC (permalink / raw)
  To: gcc-bugs

with the following test program, gcc-4.0 doesn't emit the required function
canonicalization code (calls to __canonicalize_funcptr_for_compare) to do the
comparison when optimization is enabled.

tausq@riot:/tmp/dl$ gcc-3.3 -D_GNU_SOURCE -O2 -o default default.c -ldl;
./default; echo $?
0

tausq@riot:/tmp/dl$ gcc-4.0 -D_GNU_SOURCE -O2 -o default default.c -ldl;
./default; echo $?
1


#include <dlfcn.h>
#include <stdio.h>

int
main (int argc, char *argv[])
{
  void *p;

  /* Find function `main'.  */
  p = dlsym (RTLD_DEFAULT, "main");
  if (p == NULL)
    return -1;
  else if ((int (*)(int, char **))p != main)
    return 1;
  else
    return 0;
 }

-- 
           Summary: [4.0 regression] Wrong code for function pointer
                    comparision during optimization
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tausq at debian dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: hppa-unknown-linux
  GCC host triplet: hppa-unknown-linux
GCC target triplet: hppa-unknown-linux


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


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

* [Bug tree-optimization/22051] [4.0 regression/hppa-linux] Wrong code for function pointer comparision during optimization
  2005-06-13 16:14 [Bug tree-optimization/22051] New: [4.0 regression] Wrong code for function pointer comparision during optimization tausq at debian dot org
@ 2005-06-13 16:16 ` tausq at debian dot org
  2005-06-13 16:20 ` [Bug middle-end/22051] [4.0/4.1 regression] " pinskia at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: tausq at debian dot org @ 2005-06-13 16:16 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.0.0
      Known to work|                            |3.3.5
            Summary|[4.0 regression] Wrong code |[4.0 regression/hppa-linux]
                   |for function pointer        |Wrong code for function
                   |comparision during          |pointer comparision during
                   |optimization                |optimization


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


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

* [Bug middle-end/22051] [4.0/4.1 regression] Wrong code for function pointer comparision during optimization
  2005-06-13 16:14 [Bug tree-optimization/22051] New: [4.0 regression] Wrong code for function pointer comparision during optimization tausq at debian dot org
  2005-06-13 16:16 ` [Bug tree-optimization/22051] [4.0 regression/hppa-linux] " tausq at debian dot org
@ 2005-06-13 16:20 ` pinskia at gcc dot gnu dot org
  2005-06-13 16:24 ` randolph at tausq dot org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-13 16:20 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-13 16:20 -------
I thought this was fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|tree-optimization           |middle-end
  GCC build triplet|hppa-unknown-linux          |
   GCC host triplet|hppa-unknown-linux          |
           Keywords|                            |wrong-code
            Summary|[4.0 regression/hppa-linux] |[4.0/4.1 regression] Wrong
                   |Wrong code for function     |code for function pointer
                   |pointer comparision during  |comparision during
                   |optimization                |optimization
   Target Milestone|---                         |4.0.1


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


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

* [Bug middle-end/22051] [4.0/4.1 regression] Wrong code for function pointer comparision during optimization
  2005-06-13 16:14 [Bug tree-optimization/22051] New: [4.0 regression] Wrong code for function pointer comparision during optimization tausq at debian dot org
                   ` (2 preceding siblings ...)
  2005-06-13 16:24 ` randolph at tausq dot org
@ 2005-06-13 16:24 ` tausq at debian dot org
  2005-06-13 16:36 ` danglin at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: tausq at debian dot org @ 2005-06-13 16:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From tausq at debian dot org  2005-06-13 16:23 -------
this is what you get with gcc-3.3:

.LC0:
.stringz"main"
        .section        .rodata.cst4,"aM",@progbits,4
        .align 4
.LC1:
        .word   P%main
[...]
        ldil LR'.LC0,%r25
        ldi -1,%r4
        bl dlsym,%r2
        ldo RR'.LC0(%r25),%r25
        comib,= 0,%r28,.L1
        copy %r28,%r26
        bl __canonicalize_funcptr_for_compare,%r2
        nop
        ldil LR'.LC1,%r19
        copy %r28,%r4
        bl __canonicalize_funcptr_for_compare,%r2
        ldw RR'.LC1(%r19),%r26
        comclr,= %r28,%r4,%r4
        ldi 1,%r4
.L1:
        copy %r4,%r28


And with gcc-4.0, you get instead:
.LC0:
.stringz"main"
        .section        .rodata.cst4,"aM",@progbits,4
        .align 4
.LC1:
        .word   P%main
[...]
        ldil LR'.LC0,%r25
        bl dlsym,%r2
        ldo RR'.LC0(%r25),%r25
        movb,= %r28,%r20,.L4
        ldi -1,%r19
        ldil LR'.LC1,%r28
        ldw RR'.LC1(%r28),%r19
        comclr,= %r19,%r20,%r19
        ldi 1,%r19
.L4:
        copy %r19,%r28



-- 


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


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

* [Bug middle-end/22051] [4.0/4.1 regression] Wrong code for function pointer comparision during optimization
  2005-06-13 16:14 [Bug tree-optimization/22051] New: [4.0 regression] Wrong code for function pointer comparision during optimization tausq at debian dot org
  2005-06-13 16:16 ` [Bug tree-optimization/22051] [4.0 regression/hppa-linux] " tausq at debian dot org
  2005-06-13 16:20 ` [Bug middle-end/22051] [4.0/4.1 regression] " pinskia at gcc dot gnu dot org
@ 2005-06-13 16:24 ` randolph at tausq dot org
  2005-06-13 16:24 ` tausq at debian dot org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: randolph at tausq dot org @ 2005-06-13 16:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From randolph at tausq dot org  2005-06-13 16:24 -------
Subject: Re:  [4.0/4.1 regression] Wrong code for function pointer comparision during optimization

> I thought this was fixed.

Nope, sorry.

randolph


-- 


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


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

* [Bug middle-end/22051] [4.0/4.1 regression] Wrong code for function pointer comparision during optimization
  2005-06-13 16:14 [Bug tree-optimization/22051] New: [4.0 regression] Wrong code for function pointer comparision during optimization tausq at debian dot org
                   ` (3 preceding siblings ...)
  2005-06-13 16:24 ` tausq at debian dot org
@ 2005-06-13 16:36 ` danglin at gcc dot gnu dot org
  2005-06-14  0:14 ` danglin at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: danglin at gcc dot gnu dot org @ 2005-06-13 16:36 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |danglin at gcc dot gnu dot
                   |                            |org


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


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

* [Bug middle-end/22051] [4.0/4.1 regression] Wrong code for function pointer comparision during optimization
  2005-06-13 16:14 [Bug tree-optimization/22051] New: [4.0 regression] Wrong code for function pointer comparision during optimization tausq at debian dot org
                   ` (4 preceding siblings ...)
  2005-06-13 16:36 ` danglin at gcc dot gnu dot org
@ 2005-06-14  0:14 ` danglin at gcc dot gnu dot org
  2005-06-14  0:17 ` [Bug tree-optimization/22051] " pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: danglin at gcc dot gnu dot org @ 2005-06-14  0:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From danglin at gcc dot gnu dot org  2005-06-14 00:14 -------
Here's what we have at the test to see if function pointer canonicalization
should be done in dojump.c:

Breakpoint 1, do_compare_and_jump (exp=0x400ec708, signed_code=NE,
    unsigned_code=NE, if_false_label=0x400ecd70, if_true_label=0x0)
    at ../../gcc/gcc/dojump.c:928
928       if (HAVE_canonicalize_funcptr_for_compare
(gdb) p debug_tree (exp)
 <ne_expr 0x400ec708
    type <boolean_type 0x4000c620 _Bool public unsigned QI
        size <integer_cst 0x400030f0 constant invariant 8>
        unit size <integer_cst 0x40003108 constant invariant 1>
        align 8 symtab 0 alias set -1 precision 1 min <integer_cst 0x400034e0 0> 
max <integer_cst 0x40003510 1>>

    arg 0 <var_decl 0x400ef850 p
        type <pointer_type 0x400174d0 type <void_type 0x40017460 void>
            sizes-gimplified public unsigned SI
            size <integer_cst 0x400032e8 constant invariant 32>
            unit size <integer_cst 0x40003078 constant invariant 4>
            align 32 symtab 0 alias set -1
            pointer_to_this <pointer_type 0x4007fbd0>>
        used unsigned SI file cffc-bug.c line 8 size <integer_cst 0x400032e8 32> 
unit size <integer_cst 0x40003078 4>
        align 32 context <function_decl 0x400ef700 main>
        (reg/v/f:SI 94 [ p ])
        chain <var_decl 0x400ef8c0 result type <integer_type 0x4000c380 int>
            SI file cffc-bug.c line 9 size <integer_cst 0x400032e8 32> unit size 
<integer_cst 0x40003078 4>
            align 32 context <function_decl 0x400ef700 main>>>
    arg 1 <addr_expr 0x400eb820
        type <pointer_type 0x400f3070 type <function_type 0x400ef690>
            unsigned SI size <integer_cst 0x400032e8 32> unit size <integer_cst 
0x40003078 4>
            align 32 symtab 0 alias set -1>
        constant invariant
        arg 0 <function_decl 0x400ef700 main type <function_type 0x400ef690>
            addressable used public static decl_5 SI file cffc-bug.c line 7 
arguments <parm_decl 0x400ef540 argc> result <result_decl 0x400ef770 D.2328> 
initial <block 0x400f0b98>
            (mem:SI (symbol_ref/v:SI ("@main") <function_decl 0x400ef700 main>) 
[0 S4 A32])
            saved-insns 0x400de800>>>
$3 = void

The "(int (*)(int, char **))" cast appears to have been dropped from the
comparison.

I also believe that casts to int types are also being dropped when applied
to function pointer causing the opposite problem (unnecessary canonicalization).

In cffc-bug.c.t19.dce1, we have:

<L1>:;
  p___23_4 = (int (*<T4ef>) (int, char * *)) p_3;
  if (p___23_4 != main) goto <L2>; else goto <L3>;

In cffc-bug.c.t20.dom1, we have:

<L1>:;
  p___23_4 = (int (*<T4ef>) (int, char * *)) p_2;
  if (p_2 != main) goto <L2>; else goto <L3>;


-- 


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


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

* [Bug tree-optimization/22051] [4.0/4.1 regression] Wrong code for function pointer comparision during optimization
  2005-06-13 16:14 [Bug tree-optimization/22051] New: [4.0 regression] Wrong code for function pointer comparision during optimization tausq at debian dot org
                   ` (5 preceding siblings ...)
  2005-06-14  0:14 ` danglin at gcc dot gnu dot org
@ 2005-06-14  0:17 ` pinskia at gcc dot gnu dot org
  2005-06-14  0:18 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-14  0:17 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org, dnovillo at gcc dot gnu
                   |                            |dot org, law at gcc dot gnu
                   |                            |dot org
          Component|middle-end                  |tree-optimization


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


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

* [Bug tree-optimization/22051] [4.0/4.1 regression] Wrong code for function pointer comparision during optimization
  2005-06-13 16:14 [Bug tree-optimization/22051] New: [4.0 regression] Wrong code for function pointer comparision during optimization tausq at debian dot org
                   ` (6 preceding siblings ...)
  2005-06-14  0:17 ` [Bug tree-optimization/22051] " pinskia at gcc dot gnu dot org
@ 2005-06-14  0:18 ` pinskia at gcc dot gnu dot org
  2005-06-14  0:53 ` danglin at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-14  0:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-14 00:17 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-06-14 00:17:58
               date|                            |


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


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

* [Bug tree-optimization/22051] [4.0/4.1 regression] Wrong code for function pointer comparision during optimization
  2005-06-13 16:14 [Bug tree-optimization/22051] New: [4.0 regression] Wrong code for function pointer comparision during optimization tausq at debian dot org
                   ` (7 preceding siblings ...)
  2005-06-14  0:18 ` pinskia at gcc dot gnu dot org
@ 2005-06-14  0:53 ` danglin at gcc dot gnu dot org
  2005-06-24 13:24 ` mmitchel at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: danglin at gcc dot gnu dot org @ 2005-06-14  0:53 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From danglin at gcc dot gnu dot org  2005-06-14 00:53 -------
The same problem should apply to hppa2.0w-hp-hpux11.11 as it also requires
function pointer canonicalization.


-- 


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


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

* [Bug tree-optimization/22051] [4.0/4.1 regression] Wrong code for function pointer comparision during optimization
  2005-06-13 16:14 [Bug tree-optimization/22051] New: [4.0 regression] Wrong code for function pointer comparision during optimization tausq at debian dot org
                   ` (8 preceding siblings ...)
  2005-06-14  0:53 ` danglin at gcc dot gnu dot org
@ 2005-06-24 13:24 ` mmitchel at gcc dot gnu dot org
  2005-06-24 14:24 ` randolph at tausq dot org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-06-24 13:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2005-06-24 13:23 -------
The proposed patch has passed testing on x86_64-unknown-linux-gnu.

-- 


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


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

* [Bug tree-optimization/22051] [4.0/4.1 regression] Wrong code for function pointer comparision during optimization
  2005-06-13 16:14 [Bug tree-optimization/22051] New: [4.0 regression] Wrong code for function pointer comparision during optimization tausq at debian dot org
                   ` (9 preceding siblings ...)
  2005-06-24 13:24 ` mmitchel at gcc dot gnu dot org
@ 2005-06-24 14:24 ` randolph at tausq dot org
  2005-06-27  2:54 ` dave at hiauly1 dot hia dot nrc dot ca
  2005-07-01 19:04 ` law at redhat dot com
  12 siblings, 0 replies; 14+ messages in thread
From: randolph at tausq dot org @ 2005-06-24 14:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From randolph at tausq dot org  2005-06-24 14:23 -------
Subject: Re:  [4.0/4.1 regression] Wrong code for function pointer comparision during optimization

> The proposed patch has passed testing on x86_64-unknown-linux-gnu.

confirmed on hppa-linux. works on original test case.

thanks,
randolph


-- 


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


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

* [Bug tree-optimization/22051] [4.0/4.1 regression] Wrong code for function pointer comparision during optimization
  2005-06-13 16:14 [Bug tree-optimization/22051] New: [4.0 regression] Wrong code for function pointer comparision during optimization tausq at debian dot org
                   ` (10 preceding siblings ...)
  2005-06-24 14:24 ` randolph at tausq dot org
@ 2005-06-27  2:54 ` dave at hiauly1 dot hia dot nrc dot ca
  2005-07-01 19:04 ` law at redhat dot com
  12 siblings, 0 replies; 14+ messages in thread
From: dave at hiauly1 dot hia dot nrc dot ca @ 2005-06-27  2:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dave at hiauly1 dot hia dot nrc dot ca  2005-06-27 02:53 -------
Subject: Re:  [4.0/4.1 regression] Wrong code for function pointer comparision during optimization

>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>  GCC target triplet|hppa-*-linux, hppa2.0w-hp-  |hppa*-*-{linux,hpux}
>                    |hpux11.11                   |

This problem doesn't affect hppa64 as it doesn't require function
pointer canonicalization.

Dave


-- 


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


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

* [Bug tree-optimization/22051] [4.0/4.1 regression] Wrong code for function pointer comparision during optimization
  2005-06-13 16:14 [Bug tree-optimization/22051] New: [4.0 regression] Wrong code for function pointer comparision during optimization tausq at debian dot org
                   ` (11 preceding siblings ...)
  2005-06-27  2:54 ` dave at hiauly1 dot hia dot nrc dot ca
@ 2005-07-01 19:04 ` law at redhat dot com
  12 siblings, 0 replies; 14+ messages in thread
From: law at redhat dot com @ 2005-07-01 19:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From law at redhat dot com  2005-07-01 19:04 -------
Fixed by this patch:

http://gcc.gnu.org/ml/gcc-patches/2005-06/msg02278.html

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


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


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

end of thread, other threads:[~2005-07-01 19:04 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-13 16:14 [Bug tree-optimization/22051] New: [4.0 regression] Wrong code for function pointer comparision during optimization tausq at debian dot org
2005-06-13 16:16 ` [Bug tree-optimization/22051] [4.0 regression/hppa-linux] " tausq at debian dot org
2005-06-13 16:20 ` [Bug middle-end/22051] [4.0/4.1 regression] " pinskia at gcc dot gnu dot org
2005-06-13 16:24 ` randolph at tausq dot org
2005-06-13 16:24 ` tausq at debian dot org
2005-06-13 16:36 ` danglin at gcc dot gnu dot org
2005-06-14  0:14 ` danglin at gcc dot gnu dot org
2005-06-14  0:17 ` [Bug tree-optimization/22051] " pinskia at gcc dot gnu dot org
2005-06-14  0:18 ` pinskia at gcc dot gnu dot org
2005-06-14  0:53 ` danglin at gcc dot gnu dot org
2005-06-24 13:24 ` mmitchel at gcc dot gnu dot org
2005-06-24 14:24 ` randolph at tausq dot org
2005-06-27  2:54 ` dave at hiauly1 dot hia dot nrc dot ca
2005-07-01 19:04 ` law at redhat dot com

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).