https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97926
--- Comment #3 from acsawdey at gcc dot gnu.org --- So the underlying problem here is that the unordered comparisons are not allowed with -ffinite-math-only due to this predicate: ;; Return 1 if OP is a comparison operation that is valid for a branch ;; instruction. We check the opcode against the mode of the CC value. ;; validate_condition_mode is an assertion. (define_predicate "branch_comparison_operator" (and (match_operand 0 "comparison_operator") (match_test "GET_MODE_CLASS (GET_MODE (XEXP (op, 0))) == MODE_CC") (if_then_else (match_test "GET_MODE (XEXP (op, 0)) == CCFPmode") (if_then_else (match_test "flag_finite_math_only") (match_code "lt,le,gt,ge,eq,ne,unordered,ordered") (match_code "lt,gt,eq,unordered,unge,unle,ne,ordered")) (match_code "lt,ltu,le,leu,gt,gtu,ge,geu,eq,ne")) (match_test "validate_condition_mode (GET_CODE (op), GET_MODE (XEXP (op, 0))), 1"))) But ubsan_instrument_float_cast() generates this: t = fold_build2 (UNLE_EXPR, boolean_type_node, expr, min); tt = fold_build2 (UNGE_EXPR, boolean_type_node, expr, max); which eventually leads to the ICE. Even if this branch wasn't rewritten by patch_dump_insn() it would not be recognized and would eventually ICE. Segher is working on a change to that predicate for PR98092 though which may be a workaround fix for this.