diff mbox series

Small -ftrapv improvement

Message ID 20180206203555.GD5867@tucnak
State New
Headers show
Series Small -ftrapv improvement | expand

Commit Message

Jakub Jelinek Feb. 6, 2018, 8:35 p.m. UTC
Hi!

As mentioned on IRC, operation_could_trap_helper_p returns true
for division or modulo with -ftrapv; the operations could trap in certain
cases (e.g. division by -1 of minimum signed value, but we don't have any
library functions for division/modulo for -ftrapv nor instrument it in any
way).  The following just makes it match what we implement.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2018-02-06  Jakub Jelinek  <jakub@redhat.com>

	* tree-eh.c (operation_could_trap_helper_p): Ignore honor_trapv for
	*DIV_EXPR and *MOD_EXPR.


	Jakub

Comments

Richard Biener Feb. 7, 2018, 10:16 a.m. UTC | #1
On Tue, 6 Feb 2018, Jakub Jelinek wrote:

> Hi!
> 
> As mentioned on IRC, operation_could_trap_helper_p returns true
> for division or modulo with -ftrapv; the operations could trap in certain
> cases (e.g. division by -1 of minimum signed value, but we don't have any
> library functions for division/modulo for -ftrapv nor instrument it in any
> way).  The following just makes it match what we implement.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2018-02-06  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* tree-eh.c (operation_could_trap_helper_p): Ignore honor_trapv for
> 	*DIV_EXPR and *MOD_EXPR.
> 
> --- gcc/tree-eh.c.jj	2018-02-01 11:07:24.000000000 +0100
> +++ gcc/tree-eh.c	2018-02-03 17:52:40.573255559 +0100
> @@ -2436,7 +2436,7 @@ operation_could_trap_helper_p (enum tree
>      case ROUND_MOD_EXPR:
>      case TRUNC_MOD_EXPR:
>      case RDIV_EXPR:
> -      if (honor_snans || honor_trapv)
> +      if (honor_snans)
>  	return true;
>        if (fp_operation)
>  	return flag_trapping_math;
> 
> 	Jakub
> 
>
diff mbox series

Patch

--- gcc/tree-eh.c.jj	2018-02-01 11:07:24.000000000 +0100
+++ gcc/tree-eh.c	2018-02-03 17:52:40.573255559 +0100
@@ -2436,7 +2436,7 @@  operation_could_trap_helper_p (enum tree
     case ROUND_MOD_EXPR:
     case TRUNC_MOD_EXPR:
     case RDIV_EXPR:
-      if (honor_snans || honor_trapv)
+      if (honor_snans)
 	return true;
       if (fp_operation)
 	return flag_trapping_math;