From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EF25C385840B; Thu, 11 Apr 2024 06:56:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF25C385840B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712818606; bh=BLmYhQEvAYYzjXijPGJdGWuUBUyekFO+AKjnrkvAfsE=; h=From:To:Subject:Date:From; b=SZ9ylJuMIqyO4l/gxDBlo9+4AU7TlKRfmvXryJp3iotp1WzZuPXJoe3rSterqSu7l yZ45BLTjBtp72yGt+BGuZhe/Wc/GqTfeU8ex5Yji/z7DYsOYYe4j/88G9Yck+RpEyu rATOjOUk+e3kxjwXUYLsRmL2CNnb9vA/XWLEsgYQ= From: "absoler at smail dot nju.edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/114688] New: repeat load argument of an inline function Date: Thu, 11 Apr 2024 06:56:45 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 13.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: absoler at smail dot nju.edu.cn 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114688 Bug ID: 114688 Summary: repeat load argument of an inline function Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: absoler at smail dot nju.edu.cn Target Milestone: --- Hi, here's the case, regression from gcc-10, x86-64 ``` char g; int v; void foo(char p_17); void func_1() { foo(g); } void foo(char c) {=20 v =3D (char)(2 - c) & c;=20 } ``` -O2 produce this for `func_1`: ``` : foo(): 401130: mov $0x2,%eax 401135: sub 0x2ef5(%rip),%al # 404030 40113b: and 0x2eef(%rip),%al # 404030 401141: movsbl %al,%eax 401144: mov %eax,0x2ee2(%rip) # 40402c func_1(): 40114a: retq ``` it seems register allocator feels it's better to repeat load `g` instead of generating an extra `mov` to load it. while clang-trunk choose to do so: https://godbolt.org/z/bqxz8fMYn=