]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openmp-simd-clone: Match shift types
authorAndrew Stubbs <ams@codesourcery.com>
Tue, 19 Jul 2022 10:16:09 +0000 (11:16 +0100)
committerAndrew Stubbs <ams@codesourcery.com>
Tue, 2 Aug 2022 10:47:50 +0000 (11:47 +0100)
Ensure that both parameters to vector shifts use the same mode.  This is most
important for amdgcn where the masks are DImode.

gcc/ChangeLog:

* omp-simd-clone.cc (simd_clone_adjust): Convert shift_cnt to match
the mask type.

Co-authored-by: Jakub Jelinek <jakub@redhat.com>
(cherry picked from commit b64e937ccde286278743e8fdffea494faa46c214)

gcc/ChangeLog.omp
gcc/omp-simd-clone.cc

index a8ba3b5e78b4e49f8d2bec0acea7d266f3a94df3..08ab26da8ca512a1f7c03c5245c34c67078714e9 100644 (file)
@@ -1,3 +1,9 @@
+2022-08-02  Andrew Stubbs  <ams@codesourcery.com>
+
+       Backport from mainline:
+       * omp-simd-clone.cc (simd_clone_adjust): Convert shift_cnt to match
+       the mask type.
+
 2022-08-02  Andrew Stubbs  <ams@codesourcery.com>
 
        Backport from mainline:
index 04fe03cde5faae9a378d9738b24f6d51f264b070..6a9351c2102a444a85fbdf8bfea3eff8444922ba 100644 (file)
@@ -1305,8 +1305,16 @@ simd_clone_adjust (struct cgraph_node *node)
                                       build_int_cst (TREE_TYPE (iter1), c));
              gsi_insert_after (&gsi, g, GSI_CONTINUE_LINKING);
            }
+         tree shift_cnt_conv = shift_cnt;
+         if (!useless_type_conversion_p (TREE_TYPE (mask),
+                                         TREE_TYPE (shift_cnt)))
+           {
+             shift_cnt_conv = make_ssa_name (TREE_TYPE (mask));
+             g = gimple_build_assign (shift_cnt_conv, NOP_EXPR, shift_cnt);
+             gsi_insert_after (&gsi, g, GSI_CONTINUE_LINKING);
+           }
          g = gimple_build_assign (make_ssa_name (TREE_TYPE (mask)),
-                                  RSHIFT_EXPR, mask, shift_cnt);
+                                  RSHIFT_EXPR, mask, shift_cnt_conv);
          gsi_insert_after (&gsi, g, GSI_CONTINUE_LINKING);
          mask = gimple_assign_lhs (g);
          g = gimple_build_assign (make_ssa_name (TREE_TYPE (mask)),