This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] rs6000: -flto forgets 'no-vsx' function attributes (PR target/70010)


Hi,

As expected in the PR, when a function is marked with no-vsx, we would
assume user has good reason to disable VSX code generation for the function.  
To avoid VSX code generation, this function should not be inlined into VSX
function. 

In previous implementation, function with non-vsx is treated as with subset
features of target with vsx, even programer set no-vsx attribute.  Following
patch prevents no-vsx function to be inlined into vsx function.

Bootstrapped/regtested on ppc64le-linux, ok for trunk?

Thanks,
Jiufu Guo

[gcc]
2019-10-12  Jiufu Guo  <guojiufu@linux.ibm.com>

	PR target/70010
	* config/rs6000/rs6000.c (rs6000_can_inline_p): Check 'vsx' feature
	for caller and callee

[gcc/testsuite]
2019-10-12  Jiufu Guo  <guojiufu@linux.ibm.com>

	PR target/70010
	* gcc.target/powerpc/inline_error.c: New test
	
---
 gcc/config/rs6000/rs6000.c                      | 14 +++++++++-----
 gcc/testsuite/gcc.target/powerpc/inline_error.c | 17 +++++++++++++++++
 2 files changed, 26 insertions(+), 5 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/inline_error.c

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index d1434a9..c38dc87 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -23978,11 +23978,15 @@ rs6000_can_inline_p (tree caller, tree callee)
       struct cl_target_option *caller_opts = TREE_TARGET_OPTION (caller_tree);
       struct cl_target_option *callee_opts = TREE_TARGET_OPTION (callee_tree);
 
-      /* Callee's options should a subset of the caller's, i.e. a vsx function
-	 can inline an altivec function but a non-vsx function can't inline a
-	 vsx function.  */
-      if ((caller_opts->x_rs6000_isa_flags & callee_opts->x_rs6000_isa_flags)
-	  == callee_opts->x_rs6000_isa_flags)
+      /* Callee's options should a subset of the caller's. In addition,
+	 vsx function should not inline function with non-vsx by which
+	 programmer may intend to disable VSX code generation.  */
+      if ((caller_opts->x_rs6000_isa_flags & OPTION_MASK_VSX)
+	  && (callee_opts->x_rs6000_isa_flags & OPTION_MASK_VSX) == 0)
+	ret = false;
+      else if ((caller_opts->x_rs6000_isa_flags
+		& callee_opts->x_rs6000_isa_flags)
+	       == callee_opts->x_rs6000_isa_flags)
 	ret = true;
     }
 
diff --git a/gcc/testsuite/gcc.target/powerpc/inline_error.c b/gcc/testsuite/gcc.target/powerpc/inline_error.c
new file mode 100644
index 0000000..78870db
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/inline_error.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -flto -mvsx" } */
+
+vector int c, a, b;
+
+static inline void __attribute__ ((__always_inline__, target ("no-vsx")))
+foo () /* { dg-error "inlining failed in call to .* target specific option mismatch" } */
+{
+  c = a + b;
+}
+
+int
+main ()
+{
+  foo (); /* { dg-message "called from here" } */
+  c = a + b;
+}
-- 
2.7.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]