------- Additional Comments From kazu at cs dot umass dot edu 2005-04-15 16:37
-------
build_binary_op builds a binary tree node for r >= (const void *) *q;
Here are the details.
(gdb) p resultcode
$2 = GE_EXPR
(gdb) call debug_tree(build_type)
<integer_type 0xb7cf5510 int public SI
size <integer_cst 0xb7ced408 type <integer_type 0xb7cf5288 bit_size_type>
constant invariant 32>
unit size <integer_cst 0xb7ced198 type <integer_type 0xb7cf521c unsigned
int> constant invariant 4>
align 32 symtab 0 alias set -1 precision 32 min <integer_cst 0xb7ced3c0
-2147483648> max <integer_cst 0xb7ced3d8 2147483647>
pointer_to_this <pointer_type 0xb7d029b4>>
(gdb) call debug_tree(op0)
<var_decl 0xb7d6a288 r
type <pointer_type 0xb7d6a21c
type <void_type 0xb7d6a1b0 void readonly VOID
align 8 symtab 0 alias set -1
pointer_to_this <pointer_type 0xb7d6a21c>>
unsigned SI
size <integer_cst 0xb7ced408 constant invariant 32>
unit size <integer_cst 0xb7ced198 constant invariant 4>
align 32 symtab 0 alias set -1>
used unsigned SI file test.c line 6 size <integer_cst 0xb7ced408 32> unit
size <integer_cst 0xb7ced198 4>
align 32 context <function_decl 0xb7d6a06c foo> initial <nop_expr
0xb7cf22c0>>
(gdb) call debug_tree(op1)
<convert_expr 0xb7cf2320
type <pointer_type 0xb7d6a21c
type <void_type 0xb7d6a1b0 void readonly VOID
align 8 symtab 0 alias set -1
pointer_to_this <pointer_type 0xb7d6a21c>>
unsigned SI
size <integer_cst 0xb7ced408 constant invariant 32>
unit size <integer_cst 0xb7ced198 constant invariant 4>
align 32 symtab 0 alias set -1>
arg 0 <indirect_ref 0xb7cf2300
type <integer_type 0xb7cf557c unsigned int public unsigned SI size
<integer_cst 0xb7ced408 32> unit size <integer_cst 0xb7ced198 4>
align 32 symtab 0 alias set -1 precision 32 min <integer_cst
0xb7ced480 0> max <integer_cst 0xb7ced468 4294967295>
pointer_to_this <pointer_type 0xb7d63e58>>
arg 0 <parm_decl 0xb7d63ec4 p type <pointer_type 0xb7d63e58>
used unsigned SI file test.c line 4 size <integer_cst 0xb7ced408 32>
unit size <integer_cst 0xb7ced198 4>
align 32 context <function_decl 0xb7d6a06c foo> result <pointer_type
0xb7d63e58> initial <pointer_type 0xb7d63e58> arg-type <pointer_type 0xb7d63e58>
arg-type-as-written <pointer_type 0xb7d63e58> chain <parm_decl 0xb7d63f30 q>>>>
Before the binary tree node is returned to the caller, build_binary_op
calls fold to fold the newly built tree node. Since the tree node is
a binary one, fold calls fold_binary. fold_binary strips what it
considers to be useless type conversion. By the time we get to the
case handling GE_EXPR, we have the following operands whose types do
not match.
(gdb) call debug_tree(arg0)
<var_decl 0xb7d6a288 r
type <pointer_type 0xb7d6a21c
type <void_type 0xb7d6a1b0 void readonly VOID
align 8 symtab 0 alias set -1
pointer_to_this <pointer_type 0xb7d6a21c>>
unsigned SI
size <integer_cst 0xb7ced408 constant invariant 32>
unit size <integer_cst 0xb7ced198 constant invariant 4>
align 32 symtab 0 alias set -1>
used unsigned SI file test.c line 6 size <integer_cst 0xb7ced408 32> unit
size <integer_cst 0xb7ced198 4>
align 32 context <function_decl 0xb7d6a06c foo> initial <nop_expr
0xb7cf22c0>>
(gdb) call debug_tree(arg1)
<indirect_ref 0xb7cf2300
type <integer_type 0xb7cf557c unsigned int public unsigned SI
size <integer_cst 0xb7ced408 constant invariant 32>
unit size <integer_cst 0xb7ced198 constant invariant 4>
align 32 symtab 0 alias set -1 precision 32 min <integer_cst 0xb7ced480
0> max <integer_cst 0xb7ced468 4294967295>
pointer_to_this <pointer_type 0xb7d63e58>>
arg 0 <parm_decl 0xb7d63ec4 p
type <pointer_type 0xb7d63e58 type <integer_type 0xb7cf557c unsigned
int>
unsigned SI size <integer_cst 0xb7ced408 32> unit size <integer_cst
0xb7ced198 4>
align 32 symtab 0 alias set -1>
used unsigned SI file test.c line 4 size <integer_cst 0xb7ced408 32>
unit size <integer_cst 0xb7ced198 4>
align 32 context <function_decl 0xb7d6a06c foo> result <pointer_type
0xb7d63e58> initial <pointer_type 0xb7d63e58> arg-type <pointer_type 0xb7d63e58>
arg-type-as-written <pointer_type 0xb7d63e58>
chain <parm_decl 0xb7d63f30 q type <pointer_type 0xb7d63e58>
unsigned SI file test.c line 4 size <integer_cst 0xb7ced408 32> unit
size <integer_cst 0xb7ced198 4>
align 32 context <function_decl 0xb7d6a06c foo> result <pointer_type
0xb7d63e58> initial <pointer_type 0xb7d63e58> arg-type <pointer_type 0xb7d63e58>
arg-type-as-written <pointer_type 0xb7d63e58>>>>
Note that arg0 is of a pointer type, whereas arg1 is of an integer
type.
Roger, I don't think it's OK to create this kind of type mismatch.
At the very least, that would complicate SSA optimizers. Thoughts?
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |roger at eyesopen dot com
Summary|Type mismatch in a |fold generates a comparison
|comparison. |of two operands whose types
| |do not match
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21024