All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: xor-neon: Replace __GNUC__ checks with CONFIG_CC_IS_GCC
@ 2019-05-28 23:57 ` Nathan Chancellor
  0 siblings, 0 replies; 18+ messages in thread
From: Nathan Chancellor @ 2019-05-28 23:57 UTC (permalink / raw)
  To: Russell King
  Cc: Nicolas Pitre, Stefan Agner, linux-arm-kernel, linux-kernel,
	Arnd Bergmann, Ard Biesheuvel, clang-built-linux,
	Nathan Chancellor, Nick Desaulniers

Currently, when compiling this code with clang, the following warning is
emitted:

    CC      arch/arm/lib/xor-neon.o
  arch/arm/lib/xor-neon.c:33:2: warning: This code requires at least
  version 4.6 of GCC [-W#warnings]

This is because clang poses as GCC 4.2.1 with its __GNUC__ conditionals
for glibc compatibility[1]:

$ echo | clang -dM -E -x c /dev/null | grep GNUC | awk '{print $2" "$3}'
__GNUC_MINOR__ 2
__GNUC_PATCHLEVEL__ 1
__GNUC_STDC_INLINE__ 1
__GNUC__ 4

As pointed out by Ard Biesheuvel and Arnd Bergmann in an earlier
thread[2], the oldest version of GCC that is currently supported is gcc
4.6 after commit cafa0010cd51 ("Raise the minimum required gcc version
to 4.6") so we do not need to check for anything older anymore.

However, just removing the version check is not enough to silence clang
because it does not recognize '#pragma GCC optimize':

  arch/arm/lib/xor-neon.c:25:13: warning: unknown pragma ignored
  [-Wunknown-pragmas]
  #pragma GCC optimize "tree-vectorize"

Looking into it further, -ftree-vectorize (which '#pragma GCC optimize
"tree-vectorize"' enables) is an alias in clang for -fvectorize[3],
which according to the documentation is on by default[4] (at least at
-O2 or -Os).

Just add the pragma when compiling with GCC so that clang does not
unnecessarily warn.

[1]: https://reviews.llvm.org/D51011#1206981
[2]: https://lore.kernel.org/lkml/CAK8P3a3NjTCgFd2dQ9KbHP8DpXf6s-ULfeU6acAYC4SDi+2qvw@mail.gmail.com/
[3]: https://github.com/llvm/llvm-project/blob/eafe8ef6f2b44ba/clang/include/clang/Driver/Options.td#L1729
[4]: https://llvm.org/docs/Vectorizers.html#usage

Link: https://github.com/ClangBuiltLinux/linux/issues/496
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 arch/arm/lib/xor-neon.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/arch/arm/lib/xor-neon.c b/arch/arm/lib/xor-neon.c
index c691b901092f..d532bc072ee4 100644
--- a/arch/arm/lib/xor-neon.c
+++ b/arch/arm/lib/xor-neon.c
@@ -22,15 +22,8 @@ MODULE_LICENSE("GPL");
  * -ftree-vectorize) to attempt to exploit implicit parallelism and emit
  * NEON instructions.
  */
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+#ifdef CONFIG_CC_IS_GCC
 #pragma GCC optimize "tree-vectorize"
-#else
-/*
- * While older versions of GCC do not generate incorrect code, they fail to
- * recognize the parallel nature of these functions, and emit plain ARM code,
- * which is known to be slower than the optimized ARM code in asm-arm/xor.h.
- */
-#warning This code requires at least version 4.6 of GCC
 #endif
 
 #pragma GCC diagnostic ignored "-Wunused-variable"
-- 
2.22.0.rc1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2019-06-01  0:29 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-28 23:57 [PATCH] ARM: xor-neon: Replace __GNUC__ checks with CONFIG_CC_IS_GCC Nathan Chancellor
2019-05-28 23:57 ` Nathan Chancellor
2019-05-30 23:00 ` Nick Desaulniers
2019-05-30 23:00   ` Nick Desaulniers
2019-05-31  8:05 ` Arnd Bergmann
2019-05-31  8:05   ` Arnd Bergmann
2019-05-31 18:32   ` Nathan Chancellor
2019-05-31 18:32     ` Nathan Chancellor
2019-05-31 19:21     ` Arnd Bergmann
2019-05-31 19:21       ` Arnd Bergmann
2019-05-31 20:06       ` Nick Desaulniers
2019-05-31 20:06         ` Nick Desaulniers
2019-05-31 20:26         ` Nathan Chancellor
2019-05-31 20:26           ` Nathan Chancellor
2019-05-31 21:03         ` Arnd Bergmann
2019-05-31 21:03           ` Arnd Bergmann
2019-06-01  0:28           ` Nathan Chancellor
2019-06-01  0:28             ` Nathan Chancellor

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.