From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1C0163858D33; Thu, 22 Feb 2024 11:03:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1C0163858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1708599836; bh=WpNojJLyfO538s8PHvVhbXmvS9HPVQ/iwVpjKVB4OGM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=s1zRjbeCCRbssXV8YQ43aoHBYFlgaCA7Ol55U6lLD9FRRVq6L8chLqBBEfEaPxZEg +6UUTzMCI2pqHgOfCV0sCIXDrQsUXSX2bLDgJKerwq9Tl7Gm2Qfub4VH0YCBZdl8iO pk2+v8ruTSKg0+4z5xhcC3CI25qDwhsHqe7ZF9ms= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114032] ifcvt may introduce UB calls to __builtin_clz(0) Date: Thu, 22 Feb 2024 11:03:55 +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: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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: 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=3D114032 --- Comment #3 from Jakub Jelinek --- In GCC 13 and earlier, .CLZ(0) was UB depending on CLZ_VALUE_DEFINED_AT_ZERO (...) !=3D 2. In GCC 14, it is always UB, and well defined is only .CLZ(0, 32) (but with = the current requirement that the second argument, value at zero, matches CLZ_VALUE_DEFINED_AT_ZERO (...) =3D=3D 2 filled in value for scalars (excep= tion for bitints). If we wanted, we could (but probably stage1 material) allow any constant se= cond argument and just expand to conditional if the value doesn't match CLZ_VALUE_DEFINED_AT_ZERO (...) !=3D 0 filled in value. But, still, for the ifcvt and vectorization it would be useful to know what= is the well defined value that will be cheapest to compute. The backends could do that e.g. by supplying details for CLZ_VALUE_DEFINED_AT_ZERO on vector modes even if scalar is undefined. Or have some third way which would say this is not UB at 0, but we don't re= ally care what value at zero it has (but then e.g. VRP would need to give up on that).=