https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63571
Bug ID: 63571 Summary: Local functions with only local aliases not regparm optimized on i686-linux Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org CC: hubicka at gcc dot gnu.org, jakub at gcc dot gnu.org, jakub at redhat dot com, mliska at suse dot cz, uros at gcc dot gnu.org Depends on: 63566 +++ This bug was initially created as a clone of Bug #63566 +++ #define A \ x += y * z; \ y = (y << ((z & 2) + 1)) \ ^ (y >> (__SIZEOF_INT__ * __CHAR_BIT__ - (z & 2) - 1)); \ z *= 7; #define B A A A A A A A A A A #define C B B B B B B B B B B static unsigned int f2 (unsigned int x, unsigned int y, unsigned int z) { C return x + y + z; } static __typeof (f2) f1 __attribute__((alias ("f2"))); __attribute__((noinline, noclone)) unsigned int f3 (unsigned int x, unsigned int y, unsigned int z) { return f1 (x, z, y) + 6; } __attribute__((noinline, noclone)) unsigned int f4 (unsigned int x, unsigned int y, unsigned int z) { return f2 (y, x, z) + 7; } __attribute__((noinline, noclone, used)) unsigned int f5 (unsigned int x, unsigned int y, unsigned int z) { return f1 (2 * x, z / 2, y + 3) - 6; } __attribute__((noinline, noclone, used)) unsigned int f6 (unsigned int x, unsigned int y, unsigned int z) { return f2 (y + 2, x | 1, z / 73) + 1; } int main () { unsigned int x = f3 (0x173214, 0x182172, 0x9314); unsigned int y = f4 (0x173214, 0x182172, 0x9314); #if __SIZEOF_INT__ * __CHAR_BIT__ == 32 if (x != 0xd8e56f78U || y != 0x494c6699U) __builtin_abort (); #endif return 0; } on i?86 -m32 -O2 doesn't use regparm calling convention for f1/f2, because f2 has alias, but as all the aliases are local too, there is no reason why it couldn't be optimized too. And the PR63566 testcase should for ICF merging use local regparm calling convention too.