From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CEB3D3858C2C; Wed, 22 Dec 2021 07:24:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CEB3D3858C2C From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103798] memchr with a (small) constant string should be expanded inline. Date: Wed, 22 Dec 2021 07:24:32 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.2.1 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW 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: component everconfirmed bug_status bug_severity short_desc cf_reconfirmed_on 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: Wed, 22 Dec 2021 07:24:32 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103798 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Component|libstdc++ |tree-optimization Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Severity|normal |enhancement Summary|Missed optimization: |memchr with a (small) |char_traits::find |constant string should be |(and thus |expanded inline. |string_view::find_first_of) | |is slow when invoked with | |short strings | Last reconfirmed| |2021-12-22 --- Comment #1 from Andrew Pinski --- Really the issue is: _8 =3D __builtin_memchr ("eE", _7, 2); if (_8 !=3D 0B) Should just be expanded to _7 =3D=3D 'e' || _7 =3D=3D 'E' . That is: int f(char a) { return __builtin_memchr ("e", a, 1) !=3D 0; } int f1(char a) { return a =3D=3D 'e'; } int g(char a) { return __builtin_memchr ("eE", a, 2) !=3D 0; } int g1(char a) { return a =3D=3D 'e' || a =3D=3D 'E'; } f and f1 should produce the same assembly and g and g1 should produce the same (similar) assembly.=