[tree-ssa] string builtins strikes back
Jan Hubicka
jh@suse.cz
Thu Dec 11 19:26:00 GMT 2003
Hi,
the folling testcase (derived from testsuite):
extern void abort (void);
extern __SIZE_TYPE__ strlen (const char *);
int x = 6;
void
main_test (void)
{
const char *const foo = "hello world";
if (strlen (foo + (x++ & 7)) != 5)
abort ();
}
Causes fold_stmt to turn gimple:
<call_expr 0x40195678
type <integer_type 0x40196570 unsigned int unsigned SI
size <integer_cst 0x40194288 constant invariant 32>
unit size <integer_cst 0x40194330 constant invariant 4>
align 32 symtab 0 alias set -1 precision 32 min <integer_cst 0x40194378 0> max <integer_cst 0x40194390 4294967295>>
nothrow
arg 0 <addr_expr 0x401a45e0
type <pointer_type 0x40267570 type <function_type 0x401d16cc>
unsigned SI
size <integer_cst 0x40194978 constant invariant 32>
unit size <integer_cst 0x401949d8 constant invariant 4>
align 32 symtab 0 alias set -1>
constant invariant
arg 0 <function_decl 0x40264740 strlen type <function_type 0x401d16cc>
addressable used nothrow public external built-in defer-output QI file a.c line 2
built-in BUILT_IN_NORMAL:BUILT_IN_STRLEN context <translation_unit_decl 0x4019615c> attributes <tree_list 0x401d2048>
(mem:QI (symbol_ref:SI ("strlen") [flags 0x41] <function_decl 0x401d1740 strlen>) [0 S1 A8]) chain <function_decl 0x40264984 strcmp>>>
arg 1 <tree_list 0x40266930
value <ssa_name 0x40266cf0 type <pointer_type 0x4026732c>
>>
a.c:15>
Into non-gimple:
<nop_expr 0x4026a000
type <integer_type 0x40196570 unsigned int unsigned SI
size <integer_cst 0x40194288 constant invariant 32>
unit size <integer_cst 0x40194330 constant invariant 4>
align 32 symtab 0 alias set -1 precision 32 min <integer_cst 0x40194378 0> max <integer_cst 0x40194390 4294967295>>
arg 0 <minus_expr 0x401959d8
type <integer_type 0x4019d89c sizetype SI
size <integer_cst 0x40194978 constant invariant 32>
unit size <integer_cst 0x401949d8 constant invariant 4>
align 32 symtab 0 alias set -1 precision 32 min <integer_cst 0x401949a8 -2147483648> max <integer_cst 0x401949c0 2147483647>>
arg 0 <integer_cst 0x402668a0 constant invariant 11>
arg 1 <nop_expr 0x401a4fa0 type <integer_type 0x4019d89c>
arg 0 <ssa_name 0x40266cd8 type <integer_type 0x40196570 unsigned int>
>>>>
What would be best to cope with this? (in this case proper folding of nops
would elliminate them) but in general I don't think this is possible in all
side cases of string builtins.
Do we want the fold_stmt to produce possibly multiple statement when this
simplifies things down? What should be the interface here?
Honza
More information about the Gcc
mailing list