[BRIGFE] The modulo in ID computation should not be needed.
authorPekka Jääskeläinen <pekka.jaaskelainen@parmance.com>
Fri, 4 May 2018 16:47:34 +0000 (16:47 +0000)
committerPekka Jääskeläinen <visit0r@gcc.gnu.org>
Fri, 4 May 2018 16:47:34 +0000 (16:47 +0000)
The case where a dim is greater than the grid size doesn't seem
to be mentioned in the specs nor tested by PRM test suite.

From-SVN: r259944

gcc/brig/ChangeLog
gcc/brig/brigfrontend/brig-code-entry-handler.cc

index 57d44b71e367893bae2c53bf2a979dc374e543ca..c68c8dd4757c4f0bf0dc60a149e514b7db3c7b3d 100644 (file)
@@ -1,3 +1,8 @@
+2018-05-04  Pekka Jääskeläinen  <pekka.jaaskelainen@parmance.com>
+
+       * brig/brigfrontend/brig-code-entry-handler.cc: The modulo in
+       ID computation should not be needed.
+
 2018-05-04  Pekka Jääskeläinen  <pekka.jaaskelainen@parmance.com>
 
        * brig/brig-lang.c: Add support for whole program
index 54b53fde291cebeb1c9e1907e9e07d11e068fd6e..36a8deb403d1a84168b78afd28c04a53d1c22c2e 100644 (file)
@@ -1048,7 +1048,6 @@ brig_code_entry_handler::expand_builtin (BrigOpcode16_t brig_opcode,
       tree local_id_var = m_parent.m_cf->m_local_id_vars[dim];
       tree wg_id_var = m_parent.m_cf->m_wg_id_vars[dim];
       tree wg_size_var = m_parent.m_cf->m_wg_size_vars[dim];
-      tree grid_size_var = m_parent.m_cf->m_grid_size_vars[dim];
 
       tree wg_id_x_wg_size = build2 (MULT_EXPR, uint32_type_node,
                                     convert (uint32_type_node, wg_id_var),
@@ -1056,15 +1055,8 @@ brig_code_entry_handler::expand_builtin (BrigOpcode16_t brig_opcode,
       tree sum
        = build2 (PLUS_EXPR, uint32_type_node, wg_id_x_wg_size, local_id_var);
 
-      /* We need a modulo here because of work-groups which have dimensions
-        larger than the grid size :( TO CHECK: is this really allowed in the
-        specs?  */
-      tree modulo
-       = build2 (TRUNC_MOD_EXPR, uint32_type_node, sum, grid_size_var);
-
       return add_temp_var (std::string ("workitemabsid_")
-                            + (char) ((int) 'x' + dim),
-                          modulo);
+                          + (char) ((int) 'x' + dim), sum);
     }
   else if (brig_opcode == BRIG_OPCODE_WORKITEMFLATID)
     {