https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127654
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrea Pinski <[email protected]>: https://gcc.gnu.org/g:0ce42336870430ad152b13f73352656b34d0541d commit r17-4785-g0ce42336870430ad152b13f73352656b34d0541d Author: Andrea Pinski <[email protected]> Date: Mon Sep 28 16:26:27 2026 -0700 phiopt: Factor out ~/- with one constant [PR127654] Factoring out negative/bit_not when defined from a convert from a boolean should happen as it allows for more phiopt optimizations in many cases. Also require the constant be 0/1 with - or ~ applied to it; that is for neg, -1 or 0 and for not, ~1 (-2) or ~0 (-1). This restricts what is done to what most likely will reduce further. We can tighten up the restriction further if needed but I think this is a reasonible heuristics and allows for what is needed to allow to fix the regression that would come from allowing -(convert)CMP in early phi-opt. This is alternative to https://gcc.gnu.org/pipermail/gcc-patches/2026-July/724647.html . Bootstrapped and tested on x86_64-linux-gnu. PR tree-optimization/127654 gcc/ChangeLog: * tree-ssa-phiopt.cc (factor_out_conditional_operation): Also allow NEGATE_EXPR and BIT_NOT_EXPR with a constant in some cases. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/ssa-ifcombine-7a.c: New test. Signed-off-by: Andrea Pinski <[email protected]>
