Targets like arm, hppa and sh64 use the lower bits of the address of functions for special purposes. Even on those targets, ---- extern void plabel32_function (void); int is_plabel32 (void) { return ((unsigned long) &plabel32_function & 3); } ---- which was the test case of PR 35705, is wrongly compiled with -O2. It seems that tree-bit-ccp optimization evaluates the expression ((unsigned long) &plabel32_function & 3) to zero always. With -fno-tree-bit-ccp, the result looks OK. For example, arm-eabi compiler outputs mov r0, #0 bx lr with -O2 and ldr r0, .L2 and r0, r0, #3 bx lr .L3: .align 2 .L2: .word plabel32_function with -O2 -fno-tree-bit-ccp. I've got similar results for hppa and sh64 compilers.
Confirmed, mine. The fix for PR35705 only extracts alignment information from function decls for the single case &fn & 1. That's odd. I'm going to simply punt for function-decls for now.
Author: rguenth Date: Tue Jan 11 14:23:20 2011 New Revision: 168661 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168661 Log: 2011-01-11 Richard Guenther <rguenther@suse.de> PR tree-optimization/47239 * tree-ssa-ccp.c (get_value_from_alignment): Punt for FUNCTION_DECLs. Modified: trunk/gcc/ChangeLog trunk/gcc/tree-ssa-ccp.c
I've tried 168661 with arm, hppa and sh64 cc1's. The problem has gone away on all these 3 targets. Thanks!
Fixed.