https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120283
Bug ID: 120283 Summary: `Transform comparisons of the form X +- C1 CMP C2 to X CMP C2 -+ C1` gimple depends on single use Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: internal-improvement Severity: normal Priority: P3 Component: tree-optimization Assignee: pinskia at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Blocks: 120206 Target Milestone: --- Forwprop for comparisons proping uses generic rather than gimple so it will cause to ignore single use in many cases. So in this case of this pattern: ``` /* Transform comparisons of the form X +- C1 CMP C2 to X CMP C2 -+ C1. */ (for cmp (eq ne) (for op (plus minus) rop (minus plus) (simplify (cmp (op@3 @0 INTEGER_CST@1) INTEGER_CST@2) (if (!TREE_OVERFLOW (@1) && !TREE_OVERFLOW (@2) && !TYPE_OVERFLOW_SANITIZED (TREE_TYPE (@0)) && !TYPE_OVERFLOW_TRAPS (TREE_TYPE (@0)) && !TYPE_SATURATING (TREE_TYPE (@0))) (with { tree res = int_const_binop (rop, @2, @1); } (if (TREE_OVERFLOW (res) && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0))) { constant_boolean_node (cmp == NE_EXPR, type); } (if (single_use (@3)) (cmp @0 { TREE_OVERFLOW (res) ? drop_tree_overflow (res) : res; })))))))) ``` forwprop ignores the single use there as it does combining into generic and then uses generic to do the simplification. I am thinking single use is not important here after all and has been ignored anyways. The pattern with single use was added with r7-502-ga8b85ce9e2bffc. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120206 [Bug 120206] Removal of forward_propagate_into_gimple_cond/forward_propagate_into_comparison