This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix ffs builtin redirection
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 27 Jan 2010 15:55:55 +0100
- Subject: [PATCH] Fix ffs builtin redirection
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
glibc on s390x has undesirable ffs PLT slots, the problem is that as there
is no __ffssi2 in libgcc on 64-bit arches, gcc puts "ffs" symbol into the
optab table to call the libc function, but doesn't do the necessary
adjustment for asm redirection of builtin ffs like is done for memcpy, abort
and many other builtins.
Fixed thusly, ok for trunk?
2010-01-27 Jakub Jelinek <jakub@redhat.com>
* builtins.c (set_builtin_user_assembler_name): Also handle
ffs if int is smaller than word.
* gcc.dg/builtin-ffs-1.c: New test.
--- gcc/builtins.c.jj 2010-01-11 10:28:50.000000000 +0100
+++ gcc/builtins.c 2010-01-27 14:16:01.000000000 +0100
@@ -13588,6 +13588,14 @@ set_builtin_user_assembler_name (tree de
case BUILT_IN_ABORT:
abort_libfunc = set_user_assembler_libfunc ("abort", asmspec);
break;
+ case BUILT_IN_FFS:
+ if (INT_TYPE_SIZE < BITS_PER_WORD)
+ {
+ set_user_assembler_libfunc ("ffs", asmspec);
+ set_optab_libfunc (ffs_optab, mode_for_size (INT_TYPE_SIZE,
+ MODE_INT, 0), "ffs");
+ }
+ break;
default:
break;
}
--- gcc/testsuite/gcc.dg/builtin-ffs-1.c.jj 2010-01-27 14:27:45.000000000 +0100
+++ gcc/testsuite/gcc.dg/builtin-ffs-1.c 2010-01-27 14:27:10.000000000 +0100
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+extern int ffs (int) __asm ("__GI_ffs") __attribute__ ((nothrow, const));
+
+int
+ffsll (long long int i)
+{
+ unsigned long long int x = i & -i;
+
+ if (x <= 0xffffffff)
+ return ffs (i);
+ else
+ return 32 + ffs (i >> 32);
+}
+
+/* { dg-final { scan-assembler-not "\nffs\n|\nffs\[^a-zA-Z0-9_\]|\[^a-zA-Z0-9_\]ffs\n" } } */
Jakub