https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116569
--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #8) > (In reply to Jennifer Schmitz from comment #7) > > Thanks for the quick reply. I tried > > > > (simplify > > (minus (convert1? @0) (convert2? (mult:c (trunc_div @@0 @@1) @1))) > > (if (INTEGRAL_TYPE_P (type) > > || (VECTOR_INTEGER_TYPE_P (type) > > && optimize_vectors_before_lowering_p ())) > > (convert (trunc_mod @0 @1)))) > > > > and the result is that the test case still ICEs, but fold-minus-1.c passes. > > Try: > INTEGRAL_TYPE_P (type) > || (VECTOR_INTEGER_TYPE_P (type) > && (optimize_vectors_before_lowering_p () > || target_supports_op_p (type, TRUNC_MOD_EXPR, optab_vector))) Oh wait the problem is this is before lowering but SVE vectors can't be lowered. I think maybe the lowering pass should handle the case where: !target_supports_op_p (type, TRUNC_MOD_EXPR, optab_vector) && target_supports_op_p (type, TRUNC_DIV_EXPR, optab_vector) && target_supports_op_p (type, MULT_EXPR, optab_vector) && target_supports_op_p (type, MINUS_EXPR, optab_vector) And expand TRUNC_MOD_EXPR there. I am thinking about adding a similar thing for MIN/MAX too.