From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7BF103858C1F; Mon, 7 Nov 2022 06:39:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7BF103858C1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667803169; bh=htkwnYjPHTH2W/YPouu/YYBnRCCJ4LNXUIn89vgGy0o=; h=From:To:Subject:Date:From; b=PNhg77XsTdkopfwJ/3lvQqsF+FxCq0I53hMm917idyEKhlxj+mznPEPdMY3xOWKfc eM3DEQL3DGU/F2l5nohxp+yP1D+eDrWdH+nLA3l7YPwFq4f7lefwWBd+5ixsRsUXVD 1g1KQZpkhGOob1SBslv0EJs/TPRvitMJu0wXHI7U= From: "i.nixman at autistici dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/107546] New: simd, redundant pcmpeqb and pxor Date: Mon, 07 Nov 2022 06:39:28 +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: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: i.nixman at autistici dot 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_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=3D107546 Bug ID: 107546 Summary: simd, redundant pcmpeqb and pxor Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: i.nixman at autistici dot org Target Milestone: --- Hello, this code sample(https://godbolt.org/z/TnGMsfMs6): ``` #include auto foo(const char *p) { const auto substr =3D _mm_loadu_si128((const __m128i *)p); return _mm_cmplt_epi8(substr, _mm_set1_epi8('0')); } ``` produces the following ASM code: ``` 1: foo(char const*): 2: movdqu xmm0, XMMWORD PTR [rdi] 3: pxor xmm1, xmm1 4: pcmpgtb xmm0, XMMWORD PTR .LC0[rip] 5: pcmpeqb xmm0, xmm1 6: ret ``` please look at line 5. is there any reason for `pcmpeqb` and `pxor` instruction? just for info, clang's output(https://godbolt.org/z/MPnvEMdhr): ``` 1: foo(char const*): 2: movdqu xmm1, xmmword ptr [rdi] 3: movdqa xmm0, xmmword ptr [rip + .LCPI0_0] 4: pcmpgtb xmm0, xmm1 5: ret ``` it looks like the issue started at version 9 and up to the current trunk.=