From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E39403858C50; Tue, 7 May 2024 21:42:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E39403858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1715118175; bh=WPpo3vx/zx96780u9apyhLR03LEeeWtS3S1ZFfXwS7Y=; h=From:To:Subject:Date:In-Reply-To:References:From; b=oc0vpHj26znpQ9D4sVj9SZaqQmZkCadhJRFLdFNgPXX+L0CudPtc4VN1nq4pAjpOg fGFkprZOF8wUP1YzVJPNuTV0gcKdlKPhIgEMHdaDhjIlhDyIPTszbJwGmGyK8jvPnq w2zuMfuglE1pj7cZrlnx56BFN56AnomrubQuJGF0= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114894] `a == 0 ? 0 : a * b` -> `a * b` likewise for `a & b` Date: Tue, 07 May 2024 21:42: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: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: pinskia 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=3D114894 --- Comment #5 from GCC Commits --- The trunk branch has been updated by Andrew Pinski : https://gcc.gnu.org/g:e472527c7b45d23e8dfd0fb767a6e663b4bc136e commit r15-307-ge472527c7b45d23e8dfd0fb767a6e663b4bc136e Author: Andrew Pinski Date: Tue Apr 30 14:45:26 2024 -0700 MATCH: Add some more value_replacement simplifications (a !=3D 0 ? expr= : 0) to match This adds a few more of what is currently done in phiopt's value_replacement to match. I noticed this when I was hooking up phiopt's value_replaceme= nt code to use match and disabling the old code. But this can be done independently from the hooking up phiopt's value_replacement as phiopt is already hooked up for simplified versions already. /* a !=3D 0 ? a / b : 0 -> a / b iff b is nonzero. */ /* a !=3D 0 ? a * b : 0 -> a * b */ /* a !=3D 0 ? a & b : 0 -> a & b */ We prefer the `cond ? a : 0` forms to allow optimization of `a * cond` which uses that form. Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR tree-optimization/114894 gcc/ChangeLog: * match.pd (`a !=3D 0 ? a / b : 0`): New pattern. (`a !=3D 0 ? a * b : 0`): New pattern. (`a !=3D 0 ? a & b : 0`): New pattern. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/phi-opt-value-5.c: New test. Signed-off-by: Andrew Pinski =