diff mbox series

[rs6000] Fix PR92566 by checking VECTOR_UNIT_NONE_P

Message ID 38ef1ea3-084b-5aa8-5ca3-31620a42978b@linux.ibm.com
State New
Headers show
Series [rs6000] Fix PR92566 by checking VECTOR_UNIT_NONE_P | expand

Commit Message

Kewen.Lin Nov. 27, 2019, 6:01 a.m. UTC
Hi,

As Segher pointed out in PR92566, we shouldn't offer some vector modes which
aren't supported under current setting.  This patch is to make it check by
VECTOR_UNIT_NONE_P which is initialized as current architecture masks.

Bootstrapped and tested on powerpc64le-linux-gnu.
Is it ok for trunk?

BR,
Kewen

----
gcc/ChangeLog

2019-11-27  Kewen Lin  <linkw@gcc.gnu.org>

	PR tree-optimization/91790
	* gcc/config/rs6000/rs6000.c (rs6000_preferred_simd_mode): Check by
	VECTOR_UNIT_NONE_P instead.

Comments

Segher Boessenkool Nov. 27, 2019, 6:05 p.m. UTC | #1
On Wed, Nov 27, 2019 at 02:01:05PM +0800, Kewen.Lin wrote:
> As Segher pointed out in PR92566, we shouldn't offer some vector modes which
> aren't supported under current setting.  This patch is to make it check by
> VECTOR_UNIT_NONE_P which is initialized as current architecture masks.
> 
> Bootstrapped and tested on powerpc64le-linux-gnu.
> Is it ok for trunk?

Okay.  Thanks!


Segher


> 2019-11-27  Kewen Lin  <linkw@gcc.gnu.org>
> 
> 	PR tree-optimization/91790
> 	* gcc/config/rs6000/rs6000.c (rs6000_preferred_simd_mode): Check by
> 	VECTOR_UNIT_NONE_P instead.
diff mbox series

Patch

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 5876714..40529e6 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -4906,30 +4906,11 @@  rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
 static machine_mode
 rs6000_preferred_simd_mode (scalar_mode mode)
 {
-  if (TARGET_VSX)
-    switch (mode)
-      {
-      case E_DFmode:
-	return V2DFmode;
-      default:;
-      }
-  if (TARGET_ALTIVEC || TARGET_VSX)
-    switch (mode)
-      {
-      case E_SFmode:
-	return V4SFmode;
-      case E_TImode:
-	return V1TImode;
-      case E_DImode:
-	return V2DImode;
-      case E_SImode:
-	return V4SImode;
-      case E_HImode:
-	return V8HImode;
-      case E_QImode:
-	return V16QImode;
-      default:;
-      }
+  opt_machine_mode vmode = mode_for_vector (mode, 16 / GET_MODE_SIZE (mode));
+
+  if (vmode.exists () && !VECTOR_UNIT_NONE_P (vmode.require ()))
+    return vmode.require ();
+
   return word_mode;
 }