Martin Sebor via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:

On 11/3/20 4:13 AM, Richard Biener wrote:
This fixes the bad assumption that sizeof (bool) == 1
Bootstrap / regtest running on x86_64-unknown-linux-gnu.
2020-11-03  Richard Biener  <rguent...@suse.de>
        PR bootstrap/97666
        * tree-vect-slp.c (vect_build_slp_tree_2): Scale
        allocation of skip_args by sizeof (bool).
---
 gcc/tree-vect-slp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index e97fbe897a7..08018a1d799 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -1428,7 +1428,7 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node,
     /* If the SLP node is a PHI (induction or reduction), terminate
      the recursion.  */
-  bool *skip_args = XALLOCAVEC (bool, nops);
+  bool *skip_args = XALLOCAVEC (bool, sizeof (bool) * nops);

This change caught my eye.  XALLOCAVEC() does the scaling:

 #define XALLOCAVEC(T, N)       ((T *) alloca (sizeof (T) * (N)))

so scaling it again doesn't make sense to me...

   memset (skip_args, 0, nops);

... especially not when it's followed by the memset call above that
doesn't do the same.  If I'm missing some subtlety it might be worth
adding a comment explaining it.

um yes, the fix I tested on powerpc-darwin was…

memset (skip_args, 0, sizeof (bool) * nops);

(I haven’t tried current master, since you pushed this change - regstrap takes most
 of a day on that machine).

Iain

Reply via email to