From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BBA903858D39; Thu, 22 Feb 2024 13:16:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BBA903858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1708607772; bh=rkRgQK1/dZWlDTcNKkYP01fogle50On4FlXzC+oy4i4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jUO+Pys5y3tJaY0Zxo5R64BDNBnbpSlujKkbbAftMphD5Iy/YIKJmoHP88J0G1BxU UYzdVtcbZIydHlnOFaSe4Dt22b3t3fnvaeCaJ+P6AbCDhwIRF5E3CMMXrE/Jf9sdqV OQ+F6mDFTIuIvfA8e4vwpEWV2g1EjKxXAaLCyKRg= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111770] predicated loads inactive lane values not modelled Date: Thu, 22 Feb 2024 13:16:12 +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: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth 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=3D111770 --- Comment #5 from Richard Biener --- (In reply to Alex Coplan from comment #4) > (In reply to Richard Biener from comment #3) > > Now, if-conversion could indeed elide the .COND_ADD for integers. It's > > problematic there only because of signed overflow undefinedness, so > > you shouldn't see it for 'unsigned' already, and adding zero is safe. >=20 > Can you elaborate on this a bit? Do you mean to say that the .COND_ADD is > only there to avoid if-conversion introducing UB due to signed overflow? No, you are right. > ISTM it's needed for correctness even without that, as the addend needn't= be > guaranteed to be zero in the general case. >=20 > > if-conversion would need to have an idea of all the ranges involved here > > so it might be a bit sophisticated to get it right. >=20 > Does what I suggested above make any sense, or do you have in mind a > different way of handling this in if-conversion? I'm wondering how ifcvt > should determine that the addend is zero in the case where the predicate = is > false. ifcvt would need to compute said fact, say, keep a lattice of the value (or value-range) that's there when the block isn't executed (simulating a disabled vector lane). A load that's going to be replaced by a .MASK_LOAD can be then known zero and this needs to be propagated through regular stmts (like the multiply). There's also .COND_* which if-conversion could actually provide the else value for - like if we have a following division to avoid dividing by zero. But that would be propagating backwards (I'd still have this usecase in mind).=