diff mbox

Fix overflow-vec-{1,2} testcases on ppc64/s390x (PR middle-end/79454)

Message ID 20170210194509.GS1849@tucnak
State New
Headers show

Commit Message

Jakub Jelinek Feb. 10, 2017, 7:45 p.m. UTC
Hi!

UBSAN_*_OVERFLOW ifns on vector types prefer to just check in a loop
for overflow, but perform the vector arithmetics on vectors.  The advantage
is that the partial results don't have to be inserted one by one into the
result vector.
This requires that there is an instruction to perform that.  We were
checking that, except that I forgot that the vector type could have an
scalar integral mode (like TImode), at which point it actually would perform
say TImode addition rather than V16QImode addition.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2017-02-10  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/79454
	* internal-fn.c (expand_vector_ubsan_overflow): Use piece-wise
	result computation whenever lhs doesn't have vector mode, not
	just when it has BLKmode.


	Jakub

Comments

Richard Biener Feb. 11, 2017, 7:25 a.m. UTC | #1
On February 10, 2017 8:45:09 PM GMT+01:00, Jakub Jelinek <jakub@redhat.com> wrote:
>Hi!
>
>UBSAN_*_OVERFLOW ifns on vector types prefer to just check in a loop
>for overflow, but perform the vector arithmetics on vectors.  The
>advantage
>is that the partial results don't have to be inserted one by one into
>the
>result vector.
>This requires that there is an instruction to perform that.  We were
>checking that, except that I forgot that the vector type could have an
>scalar integral mode (like TImode), at which point it actually would
>perform
>say TImode addition rather than V16QImode addition.
>
>Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok
>for
>trunk?

OK.

Richard.

>2017-02-10  Jakub Jelinek  <jakub@redhat.com>
>
>	PR middle-end/79454
>	* internal-fn.c (expand_vector_ubsan_overflow): Use piece-wise
>	result computation whenever lhs doesn't have vector mode, not
>	just when it has BLKmode.
>
>--- gcc/internal-fn.c.jj	2017-02-09 14:55:34.000000000 +0100
>+++ gcc/internal-fn.c	2017-02-10 15:58:50.724312535 +0100
>@@ -1909,7 +1909,7 @@ expand_vector_ubsan_overflow (location_t
>     {
>       optab op;
>       lhsr = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
>-      if (GET_MODE (lhsr) == BLKmode
>+      if (!VECTOR_MODE_P (GET_MODE (lhsr))
> 	  || (op = optab_for_tree_code (code, TREE_TYPE (arg0),
> 					optab_default)) == unknown_optab
> 	  || (optab_handler (op, TYPE_MODE (TREE_TYPE (arg0)))
>
>	Jakub
diff mbox

Patch

--- gcc/internal-fn.c.jj	2017-02-09 14:55:34.000000000 +0100
+++ gcc/internal-fn.c	2017-02-10 15:58:50.724312535 +0100
@@ -1909,7 +1909,7 @@  expand_vector_ubsan_overflow (location_t
     {
       optab op;
       lhsr = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
-      if (GET_MODE (lhsr) == BLKmode
+      if (!VECTOR_MODE_P (GET_MODE (lhsr))
 	  || (op = optab_for_tree_code (code, TREE_TYPE (arg0),
 					optab_default)) == unknown_optab
 	  || (optab_handler (op, TYPE_MODE (TREE_TYPE (arg0)))