From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BA8533857C64; Sat, 29 Aug 2020 19:39:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA8533857C64 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1598729970; bh=7G5oL22YMnJf0hJcwi5BCtHrC0tcDRQbnRjN/lARY/o=; h=From:To:Subject:Date:In-Reply-To:References:From; b=iSmYSzaunBMvHDXajaVgse76T+ayPfZo+j9lFFXIoW5pGkwEdtl5h/boAQNCYPv/h YFK2HVZMswoQIM395Wcach4VmJzOJvQnacilnqekAWc60eqKVPxsgMI7Rxm4dhsG2z 2+SUozJoQJjzeMbc/F69bF6e+aSOCUqpSGVrfS2o= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/96846] [x86] Prefer xor/test/setcc over test/setcc/movzx sequence Date: Sat, 29 Aug 2020 19:39:30 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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: cc 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 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, 29 Aug 2020 19:39:30 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96846 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #1 from Jakub Jelinek --- This is something GCC is well aware of and attempts to optimize, it has sev= eral peephole2s, starting with the ;; Convert setcc + movzbl to xor + setcc if operands don't overlap. comment in i386.md. The reason why a xor isn't added in your first function is that there is no extension in that case, usually callers will just use the 8-bit register and then the xor would be a waste of time. The second case isn't handled because there is no place to insert the xor t= o, xor modifies flags, so it can't go after the comparison that sets the flags, and in this case can't go before either, because the register is live there= (it is an operand of the comparison). So, I guess the only way around would be= to look if there is some currently unused register that could be used instead = of the one chosen by the register allocation, but that is not always the case.=