https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108757
--- Comment #24 from Jiu Fu Guo <guojiufu at gcc dot gnu.org> --- (In reply to Jiu Fu Guo from comment #23) > /* Simplify ((t + -N*M) / N + M) -> t / N: (t + -C) >> N + (C>>N) ==> t >> N > */ > (for div (trunc_div exact_div) div was not used in this matcher, yet. Here rshift is used: t/(1<<N) could be optimized to "t>>N". > (simplify > (plus (rshift (plus @0 INTEGER_CST@1) INTEGER_CST@2) INTEGER_CST@3) > (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) && > (wi::to_wide (@3) << wi::to_wide (@2)) == -wi::to_wide (@1)) > (if (TYPE_OVERFLOW_UNDEFINED (type)) > (div @0 @2) This should be "(rshift @0 @2)", otherwise it will be error if relax "TYPE_UNSIGNED (type)"