From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 025FA38555A5; Mon, 8 May 2023 07:38:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 025FA38555A5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683531504; bh=tg7m/N5Um5sVpC59I5mK+DID0dQMHedYDKE1ejPSEvE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=q0r/MJyUIww/5PPGCdCnJhJLsWRzECBMeWghrGyt4ODLB58eRZjH4nkLRV62fj5il mzQjiTwHXH5bQ6tcEKEzWiL09Zn2xuz+CibkJws25WJPO2dg/Sogsx93js5EMHb1i/ qL1nkTFKkXXblA3zBm6fqKpu00tddaQPEqVKdAlc= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/59424] Optimization issue on min/max Date: Mon, 08 May 2023 07:38:22 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.7.2 X-Bugzilla-Keywords: missed-optimization, patch 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=3D59424 --- Comment #6 from CVS Commits --- The trunk branch has been updated by Andrew Pinski : https://gcc.gnu.org/g:6d6c17e45f62cfe0b7de502af299348fca548b01 commit r14-575-g6d6c17e45f62cfe0b7de502af299348fca548b01 Author: Andrew Pinski Date: Thu Apr 27 12:21:54 2023 -0700 PHIOPT: factor out unary operations instead of just conversions After using factor_out_conditional_conversion with diamond bb, we should be able do use it also for all normal unary gimple and not just conversions. This allows to optimize PR 59424 for an example. This is also a start to optimize PR 64700 and a few others. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. An example of this is: ``` static inline unsigned long long g(int t) { unsigned t1 =3D t; return t1; } static int abs1(int a) { if (a < 0) a =3D -a; return a; } unsigned long long f(int c, int d, int e) { unsigned long long t; if (d > e) t =3D g(abs1(d)); else t =3D g(abs1(e)); return t; } ``` Which should be optimized to: _9 =3D MAX_EXPR ; _4 =3D ABS_EXPR <_9>; t_3 =3D (long long unsigned intD.16) _4; gcc/ChangeLog: * tree-ssa-phiopt.cc (factor_out_conditional_conversion): Renam= e to ... (factor_out_conditional_operation): This and add support for all unary operations. (pass_phiopt::execute): Update call to factor_out_conditional_conversion to call factor_out_conditional_operation instead. PR tree-optimization/109424 PR tree-optimization/59424 gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/abs-2.c: Update tree scan for details change in wording. * gcc.dg/tree-ssa/minmax-17.c: Likewise. * gcc.dg/tree-ssa/pr103771.c: Likewise. * gcc.dg/tree-ssa/minmax-18.c: New test. * gcc.dg/tree-ssa/minmax-19.c: New test.=