https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71991

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> The testcase misses an 'inline' on fn1 (thus all the warnings).  But yes,
> confirmed.  And I think the error is somewhat correct though I think it
> is due to some defect in target attribute handling somewhere - it works
> with "sse3" for example.

Ah, okey, this would be better sample:

$cat xf86-video/tc.i
static __attribute__ ((__always_inline__)) inline int fn1 () { return 0; }
static __attribute__ ((target("inline-all-stringops"))) inline int fn2 () { fn1
(); }

int main()
{
  fn2();
}

$ gcc xf86-video/tc.i -O2
$ gcc xf86-video/tc.i -O2 -flto
xf86-video/tc.i: In function ‘fn2’:
xf86-video/tc.i:1:55: error: inlining failed in call to always_inline ‘fn1’:
target specific option mismatch
 static __attribute__ ((__always_inline__)) inline int fn1 () { return 0; }
                                                       ^~~
xf86-video/tc.i:2:77: note: called from here
 static __attribute__ ((target("inline-all-stringops"))) inline int fn2 () {
fn1 (); }


sse3 works because ix86_can_inline_p returns true:

      /* Callee's isa options should a subset of the caller's, i.e. a SSE4
function
         can inline a SSE2 function but a SSE2 function can't inline a SSE4
         function.  */
      if ((caller_opts->x_ix86_isa_flags & callee_opts->x_ix86_isa_flags)
          != callee_opts->x_ix86_isa_flags)
        ret = false;


However following snippet is rejected w/ and w/o LTO:

cat xf86-video/tc2.i
static __attribute__ ((__always_inline__, target("sse4"))) inline int fn1 () {
return 0; }
static __attribute__ ((target("sse2"))) inline int fn2 () { fn1 (); }

int main()
{
  fn2();
}

Reply via email to