RFR: 8300865: C2: product reduction in ProdRed_Double is not vectorized

Fei Gao fgao at openjdk.org
Tue May 23 03:02:49 UTC 2023


On Fri, 19 May 2023 23:27:32 GMT, Sandhya Viswanathan <sviswanathan at openjdk.org> wrote:

> This PR fixes the problem with double reduction on x86_64. 
> 
> In the test compiler.loopopts.superword.ProdRed_Double, the product reduction loop in prodReductionImplement() was not getting vectorized when run as follows:
> jtreg -XX:CompileCommand=PrintAssembly,compiler.loopopts.superword.ProdRed_Double::prodReductionImplement compiler/loopopts/superword/ProdRed_Double.java
> The print assembly generated in the pid-xxx.log output in JTwork/scratch directory was not showing any vector_reduction_double node.
> 
> This was happening as the ReductionNode::implemented was passed a vector size of one element. For the vector reduction implemented we need to check with at least vector size of two elements.
> 
> With this PR the vector_reduction_double node is generated.
> 
> Please review.
> 
> Best Regards,
> Sandhya

src/hotspot/share/opto/superword.cpp line 3724:

> 3722:             // For vector reduction implemented check we need atleast two elements.
> 3723:             int min_vec_size = MAX2(Matcher::min_vector_size(bt), 2);
> 3724:             if (ReductionNode::implemented(use->Opcode(), min_vec_size, bt)) {

Hi @sviswa7, can we use `superword_max_vector_size()` as the input here? `MAX2(Matcher::min_vector_size(bt), 2);` may not tally with the actual situation on other 64-bit platforms. WDYT?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/14065#discussion_r1201446626


More information about the hotspot-compiler-dev mailing list