[D] Remove unchecked to_constant in VECTOR_TYPE handling
diff mbox series

Message ID mpta79bwvpn.fsf@arm.com
State New
Headers show
Series
  • [D] Remove unchecked to_constant in VECTOR_TYPE handling
Related show

Commit Message

Richard Sandiford Nov. 4, 2019, 2:40 p.m. UTC
The SVE port now tries to register variable-length VECTOR_TYPEs
at start-up, so it's no longer possible to use the asserting
to_constant on the number of vector elements.  This patch punts
on variable element counts instead, just like we do for other
things that the frontend doesn't recognise.

The brace indentation matches the surrounding style.

Tested on aarch64-linux-gnu.  OK to install?

Richard


2019-11-04  Richard Sandiford  <richard.sandiford@arm.com>

gcc/d/
	* d-builtins.cc (build_frontend_type): Cope with variable
	TYPE_VECTOR_SUBPARTS.

Comments

Jeff Law Nov. 4, 2019, 4:09 p.m. UTC | #1
On 11/4/19 7:40 AM, Richard Sandiford wrote:
> The SVE port now tries to register variable-length VECTOR_TYPEs
> at start-up, so it's no longer possible to use the asserting
> to_constant on the number of vector elements.  This patch punts
> on variable element counts instead, just like we do for other
> things that the frontend doesn't recognise.
> 
> The brace indentation matches the surrounding style.
> 
> Tested on aarch64-linux-gnu.  OK to install?
> 
> Richard
> 
> 
> 2019-11-04  Richard Sandiford  <richard.sandiford@arm.com>
> 
> gcc/d/
> 	* d-builtins.cc (build_frontend_type): Cope with variable
> 	TYPE_VECTOR_SUBPARTS.
OK
jeff

Patch
diff mbox series

Index: gcc/d/d-builtins.cc
===================================================================
--- gcc/d/d-builtins.cc	2019-08-21 14:58:05.567060154 +0100
+++ gcc/d/d-builtins.cc	2019-11-04 14:38:57.680814567 +0000
@@ -197,20 +197,23 @@  build_frontend_type (tree type)
       break;
 
     case VECTOR_TYPE:
+    {
+      unsigned HOST_WIDE_INT nunits;
+      if (!TYPE_VECTOR_SUBPARTS (type).is_constant (&nunits))
+	break;
+
       dtype = build_frontend_type (TREE_TYPE (type));
-      if (dtype)
-	{
-	  poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (type);
-	  dtype = dtype->sarrayOf (nunits.to_constant ())->addMod (mod);
+      if (!dtype)
+	break;
 
-	  if (dtype->nextOf ()->isTypeBasic () == NULL)
-	    break;
+      dtype = dtype->sarrayOf (nunits)->addMod (mod);
+      if (dtype->nextOf ()->isTypeBasic () == NULL)
+	break;
 
-	  dtype = (TypeVector::create (Loc (), dtype))->addMod (mod);
-	  builtin_converted_decls.safe_push (builtin_data (dtype, type));
-	  return dtype;
-	}
-      break;
+      dtype = (TypeVector::create (Loc (), dtype))->addMod (mod);
+      builtin_converted_decls.safe_push (builtin_data (dtype, type));
+      return dtype;
+    }
 
     case RECORD_TYPE:
     {