https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98138
--- Comment #18 from rguenther at suse dot de <rguenther at suse dot de> --- On Fri, 10 Jan 2025, linkw at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98138 > > --- Comment #17 from Kewen Lin <linkw at gcc dot gnu.org> --- > ccp1: > > t0_83 = a0_79 + a1_80; > t1_84 = a0_79 - a1_80; > t2_85 = a2_81 + a3_82; > t3_86 = a2_81 - a3_82; > _63 = t0_83 + t2_85; > tmp[i_71][0] = _63; > _64 = t0_83 - t2_85; > tmp[i_71][2] = _64; > _65 = t1_84 + t3_86; > tmp[i_71][1] = _65; > _66 = t1_84 - t3_86; > tmp[i_71][3] = _66; > i_91 = i_71 + 1; > > => > > forwprop1: > > t0_83 = a0_79 + a1_80; > t1_84 = a0_79 - a1_80; > t2_85 = a2_81 + a3_82; > t3_86 = a2_81 - a3_82; > _63 = t0_83 + t2_85; > tmp[i_71][0] = _63; > _64 = t0_83 - t2_85; > tmp[i_71][2] = _64; > _65 = t1_84 + t3_86; > tmp[i_71][1] = _65; > _73 = a3_82 - a2_81; > _66 = _73 + t1_84; // changed from t1_84 - t3_86; > tmp[i_71][3] = _66; > i_91 = i_71 + 1; > > due to match.pd rule: > > /* A - B -> A + (-B) if B is easily negatable. */ > (simplify > (minus @0 negate_expr_p@1) > (if (!FIXED_POINT_TYPE_P (type)) > (plus @0 (negate @1)))) I think this misses a :s on the negate_expr_p, but I'm not sure this "works", so eventually && single_use (@1), given the original expression doesn't go away. That said, that negate_expr_p handles (minus @0 @1) makes this canonicalization only for this case. IIRC VN tries to walk back here but forwprop will happily re-do the bad expression duplication.