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