From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9E2D03858D34; Tue, 11 Jun 2024 10:08:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9E2D03858D34 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1718100507; bh=rn4H32FSNsyKIZaMEpTd3pZTmFXjki0oX1JdOWSEO2U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kXsV8LrOzFq+NkBZsc6fuccPyLu0J/vLGJqidqMuAmY++ooj9apoC6W6T6R6wEYuI RX5LmrqCqkfroMuY0iS9pQrAhFhU9WJ6OucGvDFmHsTsD4M1TmLcxAT4tQEGYP1ib/ qmxqDkqhSanQMDGAokyMh/rkDpXCs3MNAdzODxPA= From: "blubban at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/115423] Inlined strcmp optimizes poorly Date: Tue, 11 Jun 2024 10:08:27 +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: unknown X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: blubban at gmail dot com 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: 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=3D115423 --- Comment #3 from Alfred Agrell --- strcmp (c, "ABCDEFGHabcdefgh") || strcmp (c, "ABCDEFGHfoobar") can safely be optimized to 1, you're thinking of strcmp(c, "ABCDEFGHabcdefgh")=3D=3D0 || strcmp(c, "ABCDEFGHfoobar")=3D=3D0. Optimizing to multi-byte reads would be a wrong-code. If strcmp(c, "1234567= ") does an eight-byte read, it'll segfault if c is {'e',0} four bytes before an unmapped page. Even if limiting it to aligned reads (can't segfault without crossing a pag= e), it'll annoy Valgrind. (Large reads would be safe if lhs is char[8] and not char*, or if strlen is checked before doing those reads, but both of those feel unlikely to me.)=