Bug 81921 - [6 Regression] Fails to always-inline intrinsics with -flto
Summary: [6 Regression] Fails to always-inline intrinsics with -flto
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: 7.3
Assignee: Richard Biener
URL:
Keywords: lto, rejects-valid
Depends on:
Blocks:
 
Reported: 2017-08-22 09:57 UTC by Richard Biener
Modified: 2018-06-20 08:51 UTC (History)
0 users

See Also:
Host:
Target: x86_64-*-*, i?86-*-*, aarch64, powerpc
Build:
Known to work: 4.8.5, 7.2.1, 8.0
Known to fail: 5.4.0, 6.4.0, 7.2.0
Last reconfirmed: 2017-08-22 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2017-08-22 09:57:01 UTC
With -flto free_lang_data forces a DECL_FUNCTION_SPECIFIC_TARGET node if not set
(target_option_default_node).  The way ix86_can_inline_p works this causes
behavioral differences for

extern __inline int  __attribute__((__gnu_inline__, __always_inline__, __artificial__, target("sse2")))
_mm_loadu_si128 (int const *__P)
{
    return *__P;
}   

void __attribute__((target("ssse3"))) foo (void *p)
{
  volatile int x = _mm_loadu_si128 (p);
}

with -m32 vs. -m32 -flto.  The following fixes it (and allows free-lang-data
to be turned on unconditionally).

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c  (revision 251266)
+++ config/i386/i386.c  (working copy)
@@ -7507,12 +7507,12 @@ ix86_can_inline_p (tree caller, tree cal
   tree callee_tree = DECL_FUNCTION_SPECIFIC_TARGET (callee);
 
   /* If callee has no option attributes, then it is ok to inline.  */
-  if (!callee_tree)
+  if (!callee_tree || callee_tree == target_option_default_node)
     ret = true;
 
   /* If caller has no option attributes, but callee does then it is not ok to
      inline.  */
-  else if (!caller_tree)
+  else if (!caller_tree && caller_tree != target_option_default_node)
     ret = false;
 
   else
Comment 1 Richard Biener 2017-08-24 13:45:42 UTC
Author: rguenth
Date: Thu Aug 24 13:44:35 2017
New Revision: 251333

URL: https://gcc.gnu.org/viewcvs?rev=251333&root=gcc&view=rev
Log:
2017-08-23  Richard Biener  <rguenther@suse.de>

        PR target/81921
        * targhooks.c (default_target_can_inline_p): Properly
        use target_option_default_node when no DECL_FUNCTION_SPECIFIC_TARGET
        is present and always compare.
        * config/i386/i386.c (ix86_valid_target_attribute_tree): Do not
	imply -mfpmath=sse from TARGET_SSE_P.
        (ix86_can_inline_p): Properly use target_option_default_node when
        no DECL_FUNCTION_SPECIFIC_TARGET is present and always compare.

	* gcc.target/i386/pr81921.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.target/i386/pr81921.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/targhooks.c
    trunk/gcc/testsuite/ChangeLog
Comment 2 Richard Biener 2017-08-24 13:54:58 UTC
Fixed on trunk sofar.
Comment 3 Nathan Sidwell 2017-08-25 12:33:27 UTC
Author: nathan
Date: Fri Aug 25 12:32:54 2017
New Revision: 251351

URL: https://gcc.gnu.org/viewcvs?rev=251351&root=gcc&view=rev
Log:
Retabify 2017-08-24  Richard Biener  <rguenther@suse.de>
	PR target/81921

Modified:
    trunk/gcc/ChangeLog
Comment 4 Richard Biener 2017-08-28 10:19:49 UTC
Author: rguenth
Date: Mon Aug 28 10:19:17 2017
New Revision: 251376

URL: https://gcc.gnu.org/viewcvs?rev=251376&root=gcc&view=rev
Log:
2017-08-28  Richard Biener  <rguenther@suse.de>

	Backport from mainline
	2017-08-01  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/81181
	* tree-ssa-pre.c (compute_antic_aux): Defer clean() to ...
	(compute_antic): ... end of iteration here.

	* gcc.dg/torture/pr81181.c: New testcase.

	2017-08-08  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/81723
	* tree-vect-slp.c (struct bst_traits): New hash traits.
	(bst_fail): New global.
	(vect_build_slp_tree_2): New worker, split out from ...
	(vect_build_slp_tree): ... this now wrapping it with using
	bst_fail set to cache SLP tree build fails.  Properly handle
	max_tree_size.
	(vect_analyze_slp_instance): Allocate and free bst_fail.

	* gfortran.dg/pr81723.f: New testcase.

	2017-08-24  Richard Biener  <rguenther@suse.de>

	PR target/81921
	* config/i386/i386.c: Include symbol-summary.h, ipa-prop.h
	and ipa-inline.h.
	(ix86_can_inline_p): When ix86_fpmath flags do not match
	check whether the callee uses FP math at all.

	* gcc/testsuite/gcc.target/i386/pr81921.c: New testcase.

Added:
    branches/gcc-7-branch/gcc/testsuite/gcc.dg/torture/pr81181.c
    branches/gcc-7-branch/gcc/testsuite/gcc.target/i386/pr81921.c
    branches/gcc-7-branch/gcc/testsuite/gfortran.dg/pr81723.f
Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/config/i386/i386.c
    branches/gcc-7-branch/gcc/tree-ssa-pre.c
    branches/gcc-7-branch/gcc/tree-vect-slp.c
Comment 5 Richard Biener 2017-08-28 10:39:31 UTC
Fixed for GCC 7.3.
Comment 6 Aldy Hernandez 2017-09-13 17:26:57 UTC
Author: aldyh
Date: Wed Sep 13 17:26:26 2017
New Revision: 252560

URL: https://gcc.gnu.org/viewcvs?rev=252560&root=gcc&view=rev
Log:
2017-08-23  Richard Biener  <rguenther@suse.de>

        PR target/81921
        * targhooks.c (default_target_can_inline_p): Properly
        use target_option_default_node when no DECL_FUNCTION_SPECIFIC_TARGET
        is present and always compare.
        * config/i386/i386.c (ix86_valid_target_attribute_tree): Do not
	imply -mfpmath=sse from TARGET_SSE_P.
        (ix86_can_inline_p): Properly use target_option_default_node when
        no DECL_FUNCTION_SPECIFIC_TARGET is present and always compare.

	* gcc.target/i386/pr81921.c: New testcase.

Added:
    branches/range-gen2/gcc/testsuite/gcc.target/i386/pr81921.c
Modified:
    branches/range-gen2/gcc/ChangeLog
    branches/range-gen2/gcc/config/i386/i386.c
    branches/range-gen2/gcc/targhooks.c
    branches/range-gen2/gcc/testsuite/ChangeLog
Comment 7 Aldy Hernandez 2017-09-13 17:29:49 UTC
Author: aldyh
Date: Wed Sep 13 17:29:17 2017
New Revision: 252575

URL: https://gcc.gnu.org/viewcvs?rev=252575&root=gcc&view=rev
Log:
Retabify 2017-08-24  Richard Biener  <rguenther@suse.de>
	PR target/81921

Modified:
    branches/range-gen2/gcc/ChangeLog
Comment 8 Jakub Jelinek 2017-10-10 13:28:42 UTC
GCC 5 branch is being closed
Comment 9 Richard Biener 2018-06-20 08:51:39 UTC
WONTFIX for GCC 6 which doesn't have the required infrastructure.