]> git.ipfire.org Git - thirdparty/gcc.git/commit
middle-end: Fix operation_could_trap_p for FIX_TRUNC expressions
authorSpencer Abson <spencer.abson@arm.com>
Tue, 3 Jun 2025 12:15:12 +0000 (12:15 +0000)
committerSpencer Abson <spencer.abson@arm.com>
Thu, 5 Jun 2025 09:35:02 +0000 (09:35 +0000)
commit66fc62e9c7b55f287cc523854ca330b6531760b6
tree8b28b792a8f5015be526deddc584549afc776230
parentc45cc9423d5fca4635865e1d4bc858a4a6f4d65b
middle-end: Fix operation_could_trap_p for FIX_TRUNC expressions

Floating-point to integer conversions can be inexact or invalid (e.g., due to
overflow or NaN).  However, since users of operation_could_trap_p infer the
bool FP_OPERATION argument from the expression's type, the FIX_TRUNC family
are considered non-trapping here.

This patch handles them explicitly.

gcc/ChangeLog:

* tree-eh.cc (operation_could_trap_helper_p): Cover FIX_TRUNC
expressions explicitly.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve/pr96357.c: Change to avoid producing
a conditional FIX_TRUNC_EXPR, whilst still reproducing the bug
in PR96357.
* gcc.dg/tree-ssa/ifcvt-fix-trunc-1.c: New test.
* gcc.dg/tree-ssa/ifcvt-fix-trunc-2.c: Likewise.
gcc/testsuite/gcc.dg/tree-ssa/ifcvt-fix-trunc-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/ifcvt-fix-trunc-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/pr96357.c
gcc/tree-eh.cc