From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 14B563851C1A; Sat, 20 Jun 2020 05:16:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 14B563851C1A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1592630171; bh=PW2GxlMyUT9ZiW8Sbbep6V10oVE4SfFO2kbQ1th5s9g=; h=From:To:Subject:Date:From; b=nz0K1b6G3vEZl0JO0ugHBnaME0ulaBwnTRQ59G9Yy2DVlTD2AarUTOMxgUXt4Vu1s ua4+6lM9tgW4HnUfzaIdhu2fEpDNrnmyh0CwxqsVFbJiGx6rj1WZwDXsq0hJ90TZs2 7bp1I/3oulrwlH4jJpZm9gUSVcDb1P43rPx0aiSc= From: "yyc1992 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug other/95778] New: target_clones indirection eliminates requires noinline Date: Sat, 20 Jun 2020 05:16:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: other X-Bugzilla-Version: 10.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: yyc1992 at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Jun 2020 05:16:11 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95778 Bug ID: 95778 Summary: target_clones indirection eliminates requires noinline Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: yyc1992 at gmail dot com Target Milestone: --- Compiling ``` static __attribute__((noinline,target_clones("default,avx2"))) int f2(int *= p) { asm volatile ("" :: "r"(p) : "memory"); return *p; } __attribute__((target_clones("default,avx2"))) int g2(int *p) { return f2(p); } ``` with `-fPIC -O3` generates ``` g2.avx2.0: jmp f2.avx2.0 ``` However, if any of the two `noinline` is removed, the generated code become= s, ``` g2.avx2.0: jmp f2@PLT ``` which cannot get eliminated later https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95776 I think this should be possible to do and should be possible without LTO (h= ence a slightly different bug than https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95776 even though if that on= e is fixed turning on LTO can particially fix this). Also, in this case, the `f2` should be inlinable to `g2`. However, no combination of `inline`, `always_inline`, `flatten` I've tested can do that, even though when both functions are marked with `noinline` gcc clearly knows which function is calling what so it should have no problem inlining.=