https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115863
--- Comment #1 from Li Pan <pan2.li at intel dot com> --- Thanks for reporting this. It should be this "stream.avail_out = left > (uLong)max ? max : (uInt)left;" which HIT the .SAT_TRUNC. Aka below pattern. +/* Unsigned saturation truncate, case 2, sizeof (WT) > sizeof (NT). + SAT_U_TRUNC = (NT)(MIN_EXPR (X, 255)). */ +(match (unsigned_integer_sat_trunc @0) + (convert (min @0 INTEGER_CST@1)) + (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) + && TYPE_UNSIGNED (TREE_TYPE (@0))) + (with + { + unsigned itype_precision = TYPE_PRECISION (TREE_TYPE (@0)); + unsigned otype_precision = TYPE_PRECISION (type); + wide_int trunc_max = wi::mask (otype_precision, false, itype_precision); + wide_int int_cst = wi::to_wide (@1, itype_precision); + } + (if (otype_precision < itype_precision && wi::eq_p (trunc_max, int_cst)))))) Take a quick look but failed to find something abnormal, will take a look into it.