optimization/10409: "__attribute__((const))" apparently not working for ARM

gonz@ratloop.com gonz@ratloop.com
Tue Apr 15 03:56:00 GMT 2003

>Number:         10409
>Category:       optimization
>Synopsis:       "__attribute__((const))" apparently not working for ARM
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 15 03:56:01 UTC 2003
>Originator:     Pete Gonzalez
>Release:        GCC 3.2.1 (C compiler)
Cross compiler running on Win32/Cygwin with target CPU "arm7tdmi" (ARM mode)
The "const" function attribute apparently has no effect when compiling for the arm7tdmi target CPU.  In contrast, if I compile the same code for an i386 target, the two calls to "pure_func(x)" are correctly optimized into a single call.

This seems strange, because this optimization seems like it would occur at a higher level, before machine-specific issues are considered.  (?)


int pure_func(int x) __attribute__((const));

int test(int x) {
  return pure_func(x) + pure_func(x);

Save the above code as "test.c" and then run "gcc -c -O2 -save-temps test.c".
I'm uncertain as to whether this is a bug or just a missing feature.

More information about the Gcc-bugs mailing list