From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 75ED438515D0; Tue, 22 Feb 2022 06:32:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 75ED438515D0 From: "crazylht at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/104610] memcmp () == 0 can be optimized better for avx512f Date: Tue, 22 Feb 2022 06:32:44 +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: 12.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: crazylht 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: 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: Tue, 22 Feb 2022 06:32:44 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104610 --- Comment #6 from Hongtao.liu --- (In reply to Hongtao.liu from comment #5) > (In reply to Hongtao.liu from comment #4) > > (In reply to Hongtao.liu from comment #3) > > > (In reply to Hongtao.liu from comment #2) > > > > in Gimple, there're > > > >=20 > > > > _1 =3D __builtin_memcmp_eq (a_5(D), &t[0], 32); > > > > _2 =3D _1 =3D=3D 0; > > > > _6 =3D (int) _2; > > > >=20 > > > >=20 > > > > So it's related to codegen optimization with vectorized codes for > > > > __builtin_memcmp_eq, guess we can start with size multiple of 16 by= tes? > > > >=20 > > > There's no optab or target_hook for backend to participate in optimiz= ation > But there's cbranch_optab check in can_compare_p, and i386 supports > V8SI/V4DI/V4SI/V2DI, but not for OI/TI, adding support for them? >=20 > 25899(define_expand "cbranch4" > 25900 [(set (reg:CC FLAGS_REG) > 25901 (compare:CC (match_operand:VI48_AVX 1 "register_operand") > 25902 (match_operand:VI48_AVX 2 "nonimmediate_operand"= ))) > 25903 (set (pc) (if_then_else > 25904 (match_operator 0 "bt_comparison_operator" > 25905 [(reg:CC FLAGS_REG) (const_int 0)]) > 25906 (label_ref (match_operand 3)) After supporting cbranchoi4, gcc generates _Z1fPc: .LFB0: .cfi_startproc vmovdqa .LC1(%rip), %ymm0 vpxor (%rdi), %ymm0, %ymm0 vptest %ymm0, %ymm0 sete %al vzeroupper which is optimal as clang/llvm does.=