# HG changeset patch # User njian # Date 1497947153 -28800 # Tue Jun 20 16:25:53 2017 +0800 # Node ID d96c2c146d6ca5e289d81657c8977d51f36e31d4 # Parent 3df8ef613001bbd009466ace5f365172552b1178 8181633: Vectorization fails for some multiplication with constant cases Reviewed-by: duke Contributed-by: yang.zhang@linaro.org diff --git a/src/share/vm/opto/superword.cpp b/src/share/vm/opto/superword.cpp --- a/src/share/vm/opto/superword.cpp +++ b/src/share/vm/opto/superword.cpp @@ -1070,7 +1070,7 @@ } if (isomorphic(s1, s2)) { - if (independent(s1, s2) || reduction(s1, s2)) { + if ((independent(s1, s2) && have_similar_inputs(s1, s2)) || reduction(s1, s2)) { if (!exists_at(s1, 0) && !exists_at(s2, 1)) { if (!s1->is_Mem() || are_adjacent_refs(s1, s2)) { int s1_align = alignment(s1); @@ -1148,6 +1148,20 @@ return independent_path(shallow, deep); } +//--------------------------have_similar_inputs----------------------- +// For a node pair (s1, s2) which is isomorphic and independent, +// do s1 and s2 have similar input edges? +bool SuperWord::have_similar_inputs(Node* s1, Node* s2) { + // assert(isomorphic(s1, s2) == true, "check isomorphic"); + // assert(independent(s1, s2) == true, "check independent"); + if (s1->req() > 1 && !s1->is_Store() && !s1->is_Load()) { + for (uint i = 1; i < s1->req(); i++) { + if (s1->in(i)->Opcode() != s2->in(i)->Opcode()) return false; + } + } + return true; +} + //------------------------------reduction--------------------------- // Is there a data path between s1 and s2 and the nodes reductions? bool SuperWord::reduction(Node* s1, Node* s2) { diff --git a/src/share/vm/opto/superword.hpp b/src/share/vm/opto/superword.hpp --- a/src/share/vm/opto/superword.hpp +++ b/src/share/vm/opto/superword.hpp @@ -442,6 +442,9 @@ bool isomorphic(Node* s1, Node* s2); // Is there no data path from s1 to s2 or s2 to s1? bool independent(Node* s1, Node* s2); + // For a node pair (s1, s2) which is isomorphic and independent, + // do s1 and s2 have similar input edges? + bool have_similar_inputs(Node* s1, Node* s2); // Is there a data path between s1 and s2 and both are reductions? bool reduction(Node* s1, Node* s2); // Helper for independent