https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121262
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2025-07-27 Ever confirmed|0 |1 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Confirmed, the issue is the conversion is NOT single use. So the match pattern for this is rejected: ``` (if (INTEGRAL_TYPE_P (TREE_TYPE (@0)) /* Disable this optimization if we're casting a function pointer type on targets that require function pointer canonicalization. */ && !(targetm.have_canonicalize_funcptr_for_compare () && ((POINTER_TYPE_P (TREE_TYPE (@00)) && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@00)))) || (POINTER_TYPE_P (TREE_TYPE (@10)) && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (TREE_TYPE (@10)))))) && single_use (@0)) /// THIS (if (TYPE_PRECISION (TREE_TYPE (@00)) == TYPE_PRECISION (TREE_TYPE (@0)) && (TREE_CODE (@10) == INTEGER_CST || @1 != @10) && (TYPE_UNSIGNED (TREE_TYPE (@00)) == TYPE_UNSIGNED (TREE_TYPE (@0)) || cmp == NE_EXPR || cmp == EQ_EXPR) && !POINTER_TYPE_P (TREE_TYPE (@00)) /* (int)bool:32 != (int)uint is not the same as bool:32 != (bool:32)uint since boolean types only have two valid values independent of their precision. */ && (TREE_CODE (TREE_TYPE (@00)) != BOOLEAN_TYPE || TREE_CODE (TREE_TYPE (@10)) == BOOLEAN_TYPE)) /* ??? The special-casing of INTEGER_CST conversion was in the original code and here to avoid a spurious overflow flag on the resulting constant which fold_convert produces. */ (if (TREE_CODE (@1) == INTEGER_CST) (cmp @00 { force_fit_type (TREE_TYPE (@00), wide_int::from (wi::to_wide (@1), MAX (TYPE_PRECISION (TREE_TYPE (@1)), TYPE_PRECISION (TREE_TYPE (@00))), TYPE_SIGN (TREE_TYPE (@1))), 0, TREE_OVERFLOW (@1)); }) (cmp @00 (convert @1))) (if (TYPE_PRECISION (TREE_TYPE (@0)) > TYPE_PRECISION (TREE_TYPE (@00))) /* If possible, express the comparison in the shorter mode. */ (if ((cmp == EQ_EXPR || cmp == NE_EXPR || TYPE_UNSIGNED (TREE_TYPE (@0)) == TYPE_UNSIGNED (TREE_TYPE (@00)) || (!TYPE_UNSIGNED (TREE_TYPE (@0)) && TYPE_UNSIGNED (TREE_TYPE (@00)))) && (types_match (TREE_TYPE (@10), TREE_TYPE (@00)) || ((TYPE_PRECISION (TREE_TYPE (@00)) >= TYPE_PRECISION (TREE_TYPE (@10))) && (TYPE_UNSIGNED (TREE_TYPE (@00)) == TYPE_UNSIGNED (TREE_TYPE (@10)))) || (TREE_CODE (@1) == INTEGER_CST && INTEGRAL_TYPE_P (TREE_TYPE (@00)) && int_fits_type_p (@1, TREE_TYPE (@00))))) (cmp @00 (convert @10)) ```