On 12/9/19 9:11 AM, Matthew Malcomson wrote:
On 01/11/2019 21:09, Martin Sebor wrote:
diff --git a/gcc/gimple-match-head.c b/gcc/gimple-match-head.c
index 53278168a59..d7c74a1865a 100644
--- a/gcc/gimple-match-head.c
+++ b/gcc/gimple-match-head.c
@@ -837,8 +837,8 @@ try_conditional_simplification (internal_fn ifn, 
gimple_match_op *res_op,
     gimple_match_op cond_op (gimple_match_cond (res_op->ops[0],
                                              res_op->ops[num_ops - 1]),
                           op, res_op->type, num_ops - 2);
-  for (unsigned int i = 1; i < num_ops - 1; ++i)
-    cond_op.ops[i - 1] = res_op->ops[i];
+
+  memcpy (cond_op.ops, res_op->ops + 1, (num_ops - 1) * sizeof *cond_op.ops);
     switch (num_ops - 2)
       {
       case 2:

I think this copies one extra element than the original code.

(copying `num_ops - 1` elements, while the previous loop only copied
`num_ops - 2` elements since the counter started at 1).


Yes, I think you're right.  I only noticed after I committed
the change, but didn't think it actually causes any problems
(i.e., it doesn't read past the end).  Let me know if you
think otherwise.

Martin

Reply via email to