From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 180D83858D3C; Mon, 6 Nov 2023 05:46:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 180D83858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1699249597; bh=VthJ415F7n7VN+JI4ebBu5eKoq+8fg78gpN3DUIeyiU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Njyi2YQSPzr+TSbsFsjExsDzPgFyuLe5OtdtlXzNtZlK7/zCH0DClPhctKGFtcctk SLCWraMPfcszJ6UDISqTsYBD5zQoaHsxBasj2/QePuGz0uHktzSzITzXHX8ygL8o8e Amw/87kCYybzRzFx/00d3JduxaBpB5/9yU8t66oc= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/112398] Suboptimal code generation for xor pattern on subword data Date: Mon, 06 Nov 2023 05:46:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org 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_status component everconfirmed Message-ID: In-Reply-To: References: 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=3D112398 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Status|WAITING |UNCONFIRMED Component|target |rtl-optimization Ever confirmed|1 |0 --- Comment #4 from Andrew Pinski --- Expand does: ;; _1 =3D *src_5(D); (insn 7 6 0 (set (reg:SI 134 [ _1 ]) (zero_extend:SI (mem:QI (reg/v/f:SI 138 [ srcD.2336 ]) [0 MEM[(const uint8_tD.2311 *)src_5(D) clique 1 base 1]+0 S1 A8]))) "/app/example.cpp":5:= 21 -1 (nil)) ;; work_6 =3D ~_1; (insn 8 7 9 (set (reg:SI 139) (not:SI (reg:SI 134 [ _1 ]))) "/app/example.cpp":5:13 -1 (nil)) (insn 9 8 0 (set (reg/v:SI 136 [ workD.2339 ]) (zero_extend:SI (subreg:QI (reg:SI 139) 0))) "/app/example.cpp":5:1= 3 -1 (nil)) The bigger issue we don't take into track of nonzerobits as much as we coul= d. Though the other issue when combine does the combining here: Trying 7, 8 -> 9: 7: r134:SI=3Dzero_extend([r148:SI]) REG_DEAD r148:SI 8: r139:SI=3D~r134:SI REG_DEAD r134:SI 9: r136:SI=3Dzero_extend(r139:SI#0) REG_DEAD r139:SI Failed to match this instruction: (set (reg/v:SI 136 [ workD.2339 ]) (zero_extend:SI (subreg:QI (not:SI (subreg:SI (mem:QI (reg:SI 148) [0 MEM[(const uint8_tD.2311 *)src_5(D) clique 1 base 1]+0 S1 A8]) 0)) 0))) that could be just (xor (zero_extend:SI (mem:QI (reg:SI 148) [0 MEM[(const uint8_tD.2311 *)src_5(D) clique 1 base 1]+0 S1 A8]) 0))) 255) But I am not so sure combine knows how to simplify that ...=