With the following method:
public static int vectSumOfMulAdd1(
int[] a,
int[] b,
int[] c,
int[] d) {
int total = 0;
for (int i = 0; i < LENGTH; i++) {
d[i] = (int)(a[i] * b[i] + c[i]);
total += d[i];
}
return total;
}
the main loop is not vectorized because the reduction is missed by the superword optimization. If the result of the reduction is used by a control node (Return here), the reduction is wrongly excluded.
diff --git a/src/share/vm/opto/loopTransform.cpp b/src/share/vm/opto/loopTransform.cpp
--- a/src/share/vm/opto/loopTransform.cpp
+++ b/src/share/vm/opto/loopTransform.cpp
@@ -1742,7 +1742,7 @@
// The result of the reduction must not be used in the loop
for (DUIterator_Fast imax, i = def_node->fast_outs(imax); i < imax && ok; i++) {
Node* u = def_node->fast_out(i);
- if (has_ctrl(u) && !loop->is_member(get_loop(get_ctrl(u)))) {
+ if (!loop->is_member(get_loop(ctrl_or_self(u)))) {
continue;
}
if (u == phi) {
public static int vectSumOfMulAdd1(
int[] a,
int[] b,
int[] c,
int[] d) {
int total = 0;
for (int i = 0; i < LENGTH; i++) {
d[i] = (int)(a[i] * b[i] + c[i]);
total += d[i];
}
return total;
}
the main loop is not vectorized because the reduction is missed by the superword optimization. If the result of the reduction is used by a control node (Return here), the reduction is wrongly excluded.
diff --git a/src/share/vm/opto/loopTransform.cpp b/src/share/vm/opto/loopTransform.cpp
--- a/src/share/vm/opto/loopTransform.cpp
+++ b/src/share/vm/opto/loopTransform.cpp
@@ -1742,7 +1742,7 @@
// The result of the reduction must not be used in the loop
for (DUIterator_Fast imax, i = def_node->fast_outs(imax); i < imax && ok; i++) {
Node* u = def_node->fast_out(i);
- if (has_ctrl(u) && !loop->is_member(get_loop(get_ctrl(u)))) {
+ if (!loop->is_member(get_loop(ctrl_or_self(u)))) {
continue;
}
if (u == phi) {