hotspot/src/share/vm/opto/vectornode.cpp
author goetz
Mon, 02 Nov 2015 15:52:37 +0100
changeset 34194 213af0859e7e
parent 34162 16b54851eaf6
child 46528 cf0da758e7b5
permissions -rw-r--r--
8141137: C2 fails rematerializing nodes using flag registers. Summary: Don't rem. if input stretches several live ranges. If rem., don't add SpillCopy on RegFlags edge. Reviewed-by: kvn, vlivanov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
25930
eae8b7490d2c 8054033: Remove unused references to Compile*
thartmann
parents: 24923
diff changeset
     2
 * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2105
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2105
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2105
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    24
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "memory/allocation.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "opto/connode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "opto/vectornode.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
//------------------------------VectorNode--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// Return the vector operator for the specified scalar operation
14128
8e2a2d167cd4 8001101: C2: more general vector rule subsetting
dlong
parents: 13930
diff changeset
    32
// and vector length.
13490
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
    33
int VectorNode::opcode(int sopc, BasicType bt) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  switch (sopc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  case Op_AddI:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
    switch (bt) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
    case T_BOOLEAN:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
    case T_BYTE:      return Op_AddVB;
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
    39
    case T_CHAR:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
    case T_SHORT:     return Op_AddVS;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
    case T_INT:       return Op_AddVI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  case Op_AddL:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    assert(bt == T_LONG, "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    return Op_AddVL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  case Op_AddF:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    assert(bt == T_FLOAT, "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    return Op_AddVF;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  case Op_AddD:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    assert(bt == T_DOUBLE, "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    return Op_AddVD;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  case Op_SubI:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    switch (bt) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    case T_BOOLEAN:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    case T_BYTE:   return Op_SubVB;
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
    57
    case T_CHAR:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    case T_SHORT:  return Op_SubVS;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    case T_INT:    return Op_SubVI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  case Op_SubL:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    assert(bt == T_LONG, "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    return Op_SubVL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  case Op_SubF:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    assert(bt == T_FLOAT, "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    return Op_SubVF;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  case Op_SubD:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    assert(bt == T_DOUBLE, "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    return Op_SubVD;
13485
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
    71
  case Op_MulI:
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
    72
    switch (bt) {
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
    73
    case T_BOOLEAN:
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
    74
    case T_BYTE:   return 0;   // Unimplemented
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
    75
    case T_CHAR:
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
    76
    case T_SHORT:  return Op_MulVS;
14128
8e2a2d167cd4 8001101: C2: more general vector rule subsetting
dlong
parents: 13930
diff changeset
    77
    case T_INT:    return Op_MulVI;
13485
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
    78
    }
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
    79
    ShouldNotReachHere();
30624
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30211
diff changeset
    80
  case Op_MulL:
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30211
diff changeset
    81
    assert(bt == T_LONG, "must be");
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30211
diff changeset
    82
    return Op_MulVL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  case Op_MulF:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    assert(bt == T_FLOAT, "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    return Op_MulVF;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  case Op_MulD:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    assert(bt == T_DOUBLE, "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    return Op_MulVD;
33469
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33155
diff changeset
    89
  case Op_CMoveD:
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33155
diff changeset
    90
    assert(bt == T_DOUBLE, "must be");
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33155
diff changeset
    91
    return Op_CMoveVD;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  case Op_DivF:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    assert(bt == T_FLOAT, "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    return Op_DivVF;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  case Op_DivD:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    assert(bt == T_DOUBLE, "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    return Op_DivVD;
33088
34fe49ecee13 8138583: aarch64: add support for vectorizing fabs/fneg
enevill
parents: 32723
diff changeset
    98
  case Op_AbsF:
34fe49ecee13 8138583: aarch64: add support for vectorizing fabs/fneg
enevill
parents: 32723
diff changeset
    99
    assert(bt == T_FLOAT, "must be");
34fe49ecee13 8138583: aarch64: add support for vectorizing fabs/fneg
enevill
parents: 32723
diff changeset
   100
    return Op_AbsVF;
34fe49ecee13 8138583: aarch64: add support for vectorizing fabs/fneg
enevill
parents: 32723
diff changeset
   101
  case Op_AbsD:
34fe49ecee13 8138583: aarch64: add support for vectorizing fabs/fneg
enevill
parents: 32723
diff changeset
   102
    assert(bt == T_DOUBLE, "must be");
34fe49ecee13 8138583: aarch64: add support for vectorizing fabs/fneg
enevill
parents: 32723
diff changeset
   103
    return Op_AbsVD;
34fe49ecee13 8138583: aarch64: add support for vectorizing fabs/fneg
enevill
parents: 32723
diff changeset
   104
  case Op_NegF:
34fe49ecee13 8138583: aarch64: add support for vectorizing fabs/fneg
enevill
parents: 32723
diff changeset
   105
    assert(bt == T_FLOAT, "must be");
34fe49ecee13 8138583: aarch64: add support for vectorizing fabs/fneg
enevill
parents: 32723
diff changeset
   106
    return Op_NegVF;
34fe49ecee13 8138583: aarch64: add support for vectorizing fabs/fneg
enevill
parents: 32723
diff changeset
   107
  case Op_NegD:
34fe49ecee13 8138583: aarch64: add support for vectorizing fabs/fneg
enevill
parents: 32723
diff changeset
   108
    assert(bt == T_DOUBLE, "must be");
34fe49ecee13 8138583: aarch64: add support for vectorizing fabs/fneg
enevill
parents: 32723
diff changeset
   109
    return Op_NegVD;
32723
56534fb3d71a 8135028: support for vectorizing double precision sqrt
mcberg
parents: 31035
diff changeset
   110
  case Op_SqrtD:
56534fb3d71a 8135028: support for vectorizing double precision sqrt
mcberg
parents: 31035
diff changeset
   111
    assert(bt == T_DOUBLE, "must be");
56534fb3d71a 8135028: support for vectorizing double precision sqrt
mcberg
parents: 31035
diff changeset
   112
    return Op_SqrtVD;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  case Op_LShiftI:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    switch (bt) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    case T_BOOLEAN:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    case T_BYTE:   return Op_LShiftVB;
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   117
    case T_CHAR:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    case T_SHORT:  return Op_LShiftVS;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    case T_INT:    return Op_LShiftVI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    ShouldNotReachHere();
13485
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   122
  case Op_LShiftL:
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   123
    assert(bt == T_LONG, "must be");
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   124
    return Op_LShiftVL;
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   125
  case Op_RShiftI:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    switch (bt) {
14131
e376e3d428c9 8001183: incorrect results of char vectors right shift operaiton
kvn
parents: 14128
diff changeset
   127
    case T_BOOLEAN:return Op_URShiftVB; // boolean is unsigned value
e376e3d428c9 8001183: incorrect results of char vectors right shift operaiton
kvn
parents: 14128
diff changeset
   128
    case T_CHAR:   return Op_URShiftVS; // char is unsigned value
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   129
    case T_BYTE:   return Op_RShiftVB;
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   130
    case T_SHORT:  return Op_RShiftVS;
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   131
    case T_INT:    return Op_RShiftVI;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    ShouldNotReachHere();
13485
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   134
  case Op_RShiftL:
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   135
    assert(bt == T_LONG, "must be");
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   136
    return Op_RShiftVL;
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   137
  case Op_URShiftI:
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   138
    switch (bt) {
14131
e376e3d428c9 8001183: incorrect results of char vectors right shift operaiton
kvn
parents: 14128
diff changeset
   139
    case T_BOOLEAN:return Op_URShiftVB;
e376e3d428c9 8001183: incorrect results of char vectors right shift operaiton
kvn
parents: 14128
diff changeset
   140
    case T_CHAR:   return Op_URShiftVS;
e376e3d428c9 8001183: incorrect results of char vectors right shift operaiton
kvn
parents: 14128
diff changeset
   141
    case T_BYTE:
e376e3d428c9 8001183: incorrect results of char vectors right shift operaiton
kvn
parents: 14128
diff changeset
   142
    case T_SHORT:  return 0; // Vector logical right shift for signed short
e376e3d428c9 8001183: incorrect results of char vectors right shift operaiton
kvn
parents: 14128
diff changeset
   143
                             // values produces incorrect Java result for
e376e3d428c9 8001183: incorrect results of char vectors right shift operaiton
kvn
parents: 14128
diff changeset
   144
                             // negative data because java code should convert
e376e3d428c9 8001183: incorrect results of char vectors right shift operaiton
kvn
parents: 14128
diff changeset
   145
                             // a short value into int value with sign
e376e3d428c9 8001183: incorrect results of char vectors right shift operaiton
kvn
parents: 14128
diff changeset
   146
                             // extension before a shift.
13485
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   147
    case T_INT:    return Op_URShiftVI;
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   148
    }
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   149
    ShouldNotReachHere();
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   150
  case Op_URShiftL:
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   151
    assert(bt == T_LONG, "must be");
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   152
    return Op_URShiftVL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  case Op_AndI:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  case Op_AndL:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    return Op_AndV;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  case Op_OrI:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  case Op_OrL:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    return Op_OrV;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  case Op_XorI:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  case Op_XorL:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
    return Op_XorV;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  case Op_LoadB:
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   164
  case Op_LoadUB:
2022
28ce8115a91d 6796746: rename LoadC (char) opcode class to LoadUS (unsigned short)
twisti
parents: 670
diff changeset
   165
  case Op_LoadUS:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  case Op_LoadS:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  case Op_LoadI:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  case Op_LoadL:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  case Op_LoadF:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  case Op_LoadD:
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   171
    return Op_LoadVector;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  case Op_StoreB:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  case Op_StoreC:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  case Op_StoreI:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  case Op_StoreL:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  case Op_StoreF:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  case Op_StoreD:
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   179
    return Op_StoreVector;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  return 0; // Unimplemented
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
14128
8e2a2d167cd4 8001101: C2: more general vector rule subsetting
dlong
parents: 13930
diff changeset
   184
// Also used to check if the code generator
8e2a2d167cd4 8001101: C2: more general vector rule subsetting
dlong
parents: 13930
diff changeset
   185
// supports the vector operation.
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   186
bool VectorNode::implemented(int opc, uint vlen, BasicType bt) {
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   187
  if (is_java_primitive(bt) &&
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   188
      (vlen > 1) && is_power_of_2(vlen) &&
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   189
      Matcher::vector_size_supported(bt, vlen)) {
13490
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   190
    int vopc = VectorNode::opcode(opc, bt);
34162
16b54851eaf6 8140779: Code generation fixes for avx512
iveresov
parents: 33469
diff changeset
   191
    return vopc > 0 && Matcher::match_rule_supported_vector(vopc, vlen);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  }
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   193
  return false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
13485
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   196
bool VectorNode::is_shift(Node* n) {
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   197
  switch (n->Opcode()) {
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   198
  case Op_LShiftI:
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   199
  case Op_LShiftL:
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   200
  case Op_RShiftI:
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   201
  case Op_RShiftL:
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   202
  case Op_URShiftI:
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   203
  case Op_URShiftL:
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   204
    return true;
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   205
  }
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   206
  return false;
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   207
}
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   208
13488
a9ec58a1f613 7192964: assert(false) failed: bad AD file
kvn
parents: 13485
diff changeset
   209
// Check if input is loop invariant vector.
13485
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   210
bool VectorNode::is_invariant_vector(Node* n) {
13488
a9ec58a1f613 7192964: assert(false) failed: bad AD file
kvn
parents: 13485
diff changeset
   211
  // Only Replicate vector nodes are loop invariant for now.
13485
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   212
  switch (n->Opcode()) {
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   213
  case Op_ReplicateB:
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   214
  case Op_ReplicateS:
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   215
  case Op_ReplicateI:
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   216
  case Op_ReplicateL:
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   217
  case Op_ReplicateF:
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   218
  case Op_ReplicateD:
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   219
    return true;
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   220
  }
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   221
  return false;
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   222
}
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   223
13490
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   224
// [Start, end) half-open range defining which operands are vectors
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   225
void VectorNode::vector_operands(Node* n, uint* start, uint* end) {
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   226
  switch (n->Opcode()) {
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   227
  case Op_LoadB:   case Op_LoadUB:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   228
  case Op_LoadS:   case Op_LoadUS:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   229
  case Op_LoadI:   case Op_LoadL:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   230
  case Op_LoadF:   case Op_LoadD:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   231
  case Op_LoadP:   case Op_LoadN:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   232
    *start = 0;
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   233
    *end   = 0; // no vector operands
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   234
    break;
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   235
  case Op_StoreB:  case Op_StoreC:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   236
  case Op_StoreI:  case Op_StoreL:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   237
  case Op_StoreF:  case Op_StoreD:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   238
  case Op_StoreP:  case Op_StoreN:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   239
    *start = MemNode::ValueIn;
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   240
    *end   = MemNode::ValueIn + 1; // 1 vector operand
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   241
    break;
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   242
  case Op_LShiftI:  case Op_LShiftL:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   243
  case Op_RShiftI:  case Op_RShiftL:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   244
  case Op_URShiftI: case Op_URShiftL:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   245
    *start = 1;
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   246
    *end   = 2; // 1 vector operand
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   247
    break;
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   248
  case Op_AddI: case Op_AddL: case Op_AddF: case Op_AddD:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   249
  case Op_SubI: case Op_SubL: case Op_SubF: case Op_SubD:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   250
  case Op_MulI: case Op_MulL: case Op_MulF: case Op_MulD:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   251
  case Op_DivF: case Op_DivD:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   252
  case Op_AndI: case Op_AndL:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   253
  case Op_OrI:  case Op_OrL:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   254
  case Op_XorI: case Op_XorL:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   255
    *start = 1;
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   256
    *end   = 3; // 2 vector operands
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   257
    break;
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   258
  case Op_CMoveI:  case Op_CMoveL:  case Op_CMoveF:  case Op_CMoveD:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   259
    *start = 2;
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   260
    *end   = n->req();
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   261
    break;
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   262
  default:
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   263
    *start = 1;
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   264
    *end   = n->req(); // default is all operands
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   265
  }
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   266
}
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   267
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
// Return the vector version of a scalar operation node.
25930
eae8b7490d2c 8054033: Remove unused references to Compile*
thartmann
parents: 24923
diff changeset
   269
VectorNode* VectorNode::make(int opc, Node* n1, Node* n2, uint vlen, BasicType bt) {
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   270
  const TypeVect* vt = TypeVect::make(bt, vlen);
13490
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   271
  int vopc = VectorNode::opcode(opc, bt);
13930
8df570f94294 7201026: add vector for shift count
kvn
parents: 13895
diff changeset
   272
  // This method should not be called for unimplemented vectors.
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32723
diff changeset
   273
  guarantee(vopc > 0, "Vector for '%s' is not implemented", NodeClassNames[opc]);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  switch (vopc) {
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   275
  case Op_AddVB: return new AddVBNode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   276
  case Op_AddVS: return new AddVSNode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   277
  case Op_AddVI: return new AddVINode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   278
  case Op_AddVL: return new AddVLNode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   279
  case Op_AddVF: return new AddVFNode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   280
  case Op_AddVD: return new AddVDNode(n1, n2, vt);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   281
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   282
  case Op_SubVB: return new SubVBNode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   283
  case Op_SubVS: return new SubVSNode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   284
  case Op_SubVI: return new SubVINode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   285
  case Op_SubVL: return new SubVLNode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   286
  case Op_SubVF: return new SubVFNode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   287
  case Op_SubVD: return new SubVDNode(n1, n2, vt);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   289
  case Op_MulVS: return new MulVSNode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   290
  case Op_MulVI: return new MulVINode(n1, n2, vt);
30624
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30211
diff changeset
   291
  case Op_MulVL: return new MulVLNode(n1, n2, vt);
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   292
  case Op_MulVF: return new MulVFNode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   293
  case Op_MulVD: return new MulVDNode(n1, n2, vt);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   294
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   295
  case Op_DivVF: return new DivVFNode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   296
  case Op_DivVD: return new DivVDNode(n1, n2, vt);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   297
33088
34fe49ecee13 8138583: aarch64: add support for vectorizing fabs/fneg
enevill
parents: 32723
diff changeset
   298
  case Op_AbsVF: return new AbsVFNode(n1, vt);
34fe49ecee13 8138583: aarch64: add support for vectorizing fabs/fneg
enevill
parents: 32723
diff changeset
   299
  case Op_AbsVD: return new AbsVDNode(n1, vt);
34fe49ecee13 8138583: aarch64: add support for vectorizing fabs/fneg
enevill
parents: 32723
diff changeset
   300
34fe49ecee13 8138583: aarch64: add support for vectorizing fabs/fneg
enevill
parents: 32723
diff changeset
   301
  case Op_NegVF: return new NegVFNode(n1, vt);
34fe49ecee13 8138583: aarch64: add support for vectorizing fabs/fneg
enevill
parents: 32723
diff changeset
   302
  case Op_NegVD: return new NegVDNode(n1, vt);
34fe49ecee13 8138583: aarch64: add support for vectorizing fabs/fneg
enevill
parents: 32723
diff changeset
   303
32723
56534fb3d71a 8135028: support for vectorizing double precision sqrt
mcberg
parents: 31035
diff changeset
   304
  // Currently only supports double precision sqrt
56534fb3d71a 8135028: support for vectorizing double precision sqrt
mcberg
parents: 31035
diff changeset
   305
  case Op_SqrtVD: return new SqrtVDNode(n1, vt);
56534fb3d71a 8135028: support for vectorizing double precision sqrt
mcberg
parents: 31035
diff changeset
   306
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   307
  case Op_LShiftVB: return new LShiftVBNode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   308
  case Op_LShiftVS: return new LShiftVSNode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   309
  case Op_LShiftVI: return new LShiftVINode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   310
  case Op_LShiftVL: return new LShiftVLNode(n1, n2, vt);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   311
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   312
  case Op_RShiftVB: return new RShiftVBNode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   313
  case Op_RShiftVS: return new RShiftVSNode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   314
  case Op_RShiftVI: return new RShiftVINode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   315
  case Op_RShiftVL: return new RShiftVLNode(n1, n2, vt);
13485
6c7faa516fc6 6340864: Implement vectorization optimizations in hotspot-server
kvn
parents: 13104
diff changeset
   316
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   317
  case Op_URShiftVB: return new URShiftVBNode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   318
  case Op_URShiftVS: return new URShiftVSNode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   319
  case Op_URShiftVI: return new URShiftVINode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   320
  case Op_URShiftVL: return new URShiftVLNode(n1, n2, vt);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   322
  case Op_AndV: return new AndVNode(n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   323
  case Op_OrV:  return new OrVNode (n1, n2, vt);
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   324
  case Op_XorV: return new XorVNode(n1, n2, vt);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   325
  }
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32723
diff changeset
   326
  fatal("Missed vector creation for '%s'", NodeClassNames[vopc]);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   327
  return NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   329
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   331
// Scalar promotion
25930
eae8b7490d2c 8054033: Remove unused references to Compile*
thartmann
parents: 24923
diff changeset
   332
VectorNode* VectorNode::scalar2vector(Node* s, uint vlen, const Type* opd_t) {
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   333
  BasicType bt = opd_t->array_element_basic_type();
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   334
  const TypeVect* vt = opd_t->singleton() ? TypeVect::make(opd_t, vlen)
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   335
                                          : TypeVect::make(bt, vlen);
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   336
  switch (bt) {
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   337
  case T_BOOLEAN:
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   338
  case T_BYTE:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   339
    return new ReplicateBNode(s, vt);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   340
  case T_CHAR:
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   341
  case T_SHORT:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   342
    return new ReplicateSNode(s, vt);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   343
  case T_INT:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   344
    return new ReplicateINode(s, vt);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   345
  case T_LONG:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   346
    return new ReplicateLNode(s, vt);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   347
  case T_FLOAT:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   348
    return new ReplicateFNode(s, vt);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   349
  case T_DOUBLE:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   350
    return new ReplicateDNode(s, vt);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  }
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32723
diff changeset
   352
  fatal("Type '%s' is not supported for vectors", type2name(bt));
13930
8df570f94294 7201026: add vector for shift count
kvn
parents: 13895
diff changeset
   353
  return NULL;
8df570f94294 7201026: add vector for shift count
kvn
parents: 13895
diff changeset
   354
}
8df570f94294 7201026: add vector for shift count
kvn
parents: 13895
diff changeset
   355
25930
eae8b7490d2c 8054033: Remove unused references to Compile*
thartmann
parents: 24923
diff changeset
   356
VectorNode* VectorNode::shift_count(Node* shift, Node* cnt, uint vlen, BasicType bt) {
13930
8df570f94294 7201026: add vector for shift count
kvn
parents: 13895
diff changeset
   357
  assert(VectorNode::is_shift(shift) && !cnt->is_Con(), "only variable shift count");
8df570f94294 7201026: add vector for shift count
kvn
parents: 13895
diff changeset
   358
  // Match shift count type with shift vector type.
8df570f94294 7201026: add vector for shift count
kvn
parents: 13895
diff changeset
   359
  const TypeVect* vt = TypeVect::make(bt, vlen);
8df570f94294 7201026: add vector for shift count
kvn
parents: 13895
diff changeset
   360
  switch (shift->Opcode()) {
8df570f94294 7201026: add vector for shift count
kvn
parents: 13895
diff changeset
   361
  case Op_LShiftI:
8df570f94294 7201026: add vector for shift count
kvn
parents: 13895
diff changeset
   362
  case Op_LShiftL:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   363
    return new LShiftCntVNode(cnt, vt);
13930
8df570f94294 7201026: add vector for shift count
kvn
parents: 13895
diff changeset
   364
  case Op_RShiftI:
8df570f94294 7201026: add vector for shift count
kvn
parents: 13895
diff changeset
   365
  case Op_RShiftL:
8df570f94294 7201026: add vector for shift count
kvn
parents: 13895
diff changeset
   366
  case Op_URShiftI:
8df570f94294 7201026: add vector for shift count
kvn
parents: 13895
diff changeset
   367
  case Op_URShiftL:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   368
    return new RShiftCntVNode(cnt, vt);
13930
8df570f94294 7201026: add vector for shift count
kvn
parents: 13895
diff changeset
   369
  }
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32723
diff changeset
   370
  fatal("Missed vector creation for '%s'", NodeClassNames[shift->Opcode()]);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   374
// Return initial Pack node. Additional operands added with add_opd() calls.
25930
eae8b7490d2c 8054033: Remove unused references to Compile*
thartmann
parents: 24923
diff changeset
   375
PackNode* PackNode::make(Node* s, uint vlen, BasicType bt) {
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   376
  const TypeVect* vt = TypeVect::make(bt, vlen);
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   377
  switch (bt) {
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   378
  case T_BOOLEAN:
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   379
  case T_BYTE:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   380
    return new PackBNode(s, vt);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   381
  case T_CHAR:
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   382
  case T_SHORT:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   383
    return new PackSNode(s, vt);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   384
  case T_INT:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   385
    return new PackINode(s, vt);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   386
  case T_LONG:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   387
    return new PackLNode(s, vt);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   388
  case T_FLOAT:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   389
    return new PackFNode(s, vt);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   390
  case T_DOUBLE:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   391
    return new PackDNode(s, vt);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  }
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32723
diff changeset
   393
  fatal("Type '%s' is not supported for vectors", type2name(bt));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   397
// Create a binary tree form for Packs. [lo, hi) (half-open) range
25930
eae8b7490d2c 8054033: Remove unused references to Compile*
thartmann
parents: 24923
diff changeset
   398
PackNode* PackNode::binary_tree_pack(int lo, int hi) {
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   399
  int ct = hi - lo;
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   400
  assert(is_power_of_2(ct), "power of 2");
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   401
  if (ct == 2) {
25930
eae8b7490d2c 8054033: Remove unused references to Compile*
thartmann
parents: 24923
diff changeset
   402
    PackNode* pk = PackNode::make(in(lo), 2, vect_type()->element_basic_type());
13490
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   403
    pk->add_opd(in(lo+1));
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   404
    return pk;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   406
  } else {
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   407
    int mid = lo + ct/2;
25930
eae8b7490d2c 8054033: Remove unused references to Compile*
thartmann
parents: 24923
diff changeset
   408
    PackNode* n1 = binary_tree_pack(lo,  mid);
eae8b7490d2c 8054033: Remove unused references to Compile*
thartmann
parents: 24923
diff changeset
   409
    PackNode* n2 = binary_tree_pack(mid, hi );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
13490
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   411
    BasicType bt = n1->vect_type()->element_basic_type();
d19348851d2e 7192963: assert(_in[req-1] == this) failed: Must pass arg count to 'new'
kvn
parents: 13488
diff changeset
   412
    assert(bt == n2->vect_type()->element_basic_type(), "should be the same");
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   413
    switch (bt) {
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   414
    case T_BOOLEAN:
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   415
    case T_BYTE:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   416
      return new PackSNode(n1, n2, TypeVect::make(T_SHORT, 2));
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   417
    case T_CHAR:
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   418
    case T_SHORT:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   419
      return new PackINode(n1, n2, TypeVect::make(T_INT, 2));
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   420
    case T_INT:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   421
      return new PackLNode(n1, n2, TypeVect::make(T_LONG, 2));
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   422
    case T_LONG:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   423
      return new Pack2LNode(n1, n2, TypeVect::make(T_LONG, 2));
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   424
    case T_FLOAT:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   425
      return new PackDNode(n1, n2, TypeVect::make(T_DOUBLE, 2));
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   426
    case T_DOUBLE:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   427
      return new Pack2DNode(n1, n2, TypeVect::make(T_DOUBLE, 2));
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   428
    }
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32723
diff changeset
   429
    fatal("Type '%s' is not supported for vectors", type2name(bt));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   434
// Return the vector version of a scalar load node.
25930
eae8b7490d2c 8054033: Remove unused references to Compile*
thartmann
parents: 24923
diff changeset
   435
LoadVectorNode* LoadVectorNode::make(int opc, Node* ctl, Node* mem,
31035
0f0743952c41 8077504: Unsafe load can loose control dependency and cause crash
roland
parents: 30624
diff changeset
   436
                                     Node* adr, const TypePtr* atyp,
0f0743952c41 8077504: Unsafe load can loose control dependency and cause crash
roland
parents: 30624
diff changeset
   437
                                     uint vlen, BasicType bt,
0f0743952c41 8077504: Unsafe load can loose control dependency and cause crash
roland
parents: 30624
diff changeset
   438
                                     ControlDependency control_dependency) {
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   439
  const TypeVect* vt = TypeVect::make(bt, vlen);
31035
0f0743952c41 8077504: Unsafe load can loose control dependency and cause crash
roland
parents: 30624
diff changeset
   440
  return new LoadVectorNode(ctl, mem, adr, atyp, vt, control_dependency);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   441
}
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   442
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   443
// Return the vector version of a scalar store node.
25930
eae8b7490d2c 8054033: Remove unused references to Compile*
thartmann
parents: 24923
diff changeset
   444
StoreVectorNode* StoreVectorNode::make(int opc, Node* ctl, Node* mem,
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   445
                                       Node* adr, const TypePtr* atyp, Node* val,
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   446
                                       uint vlen) {
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   447
  return new StoreVectorNode(ctl, mem, adr, atyp, val);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   448
}
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   449
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
// Extract a scalar element of vector.
25930
eae8b7490d2c 8054033: Remove unused references to Compile*
thartmann
parents: 24923
diff changeset
   451
Node* ExtractNode::make(Node* v, uint position, BasicType bt) {
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   452
  assert((int)position < Matcher::max_vector_size(bt), "pos in range");
25930
eae8b7490d2c 8054033: Remove unused references to Compile*
thartmann
parents: 24923
diff changeset
   453
  ConINode* pos = ConINode::make((int)position);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
  switch (bt) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  case T_BOOLEAN:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   456
    return new ExtractUBNode(v, pos);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  case T_BYTE:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   458
    return new ExtractBNode(v, pos);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  case T_CHAR:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   460
    return new ExtractCNode(v, pos);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  case T_SHORT:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   462
    return new ExtractSNode(v, pos);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  case T_INT:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   464
    return new ExtractINode(v, pos);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  case T_LONG:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   466
    return new ExtractLNode(v, pos);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  case T_FLOAT:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   468
    return new ExtractFNode(v, pos);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  case T_DOUBLE:
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 14131
diff changeset
   470
    return new ExtractDNode(v, pos);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  }
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32723
diff changeset
   472
  fatal("Type '%s' is not supported for vectors", type2name(bt));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
}
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   475
30211
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   476
int ReductionNode::opcode(int opc, BasicType bt) {
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   477
  int vopc = opc;
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   478
  switch (opc) {
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   479
    case Op_AddI:
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   480
      assert(bt == T_INT, "must be");
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   481
      vopc = Op_AddReductionVI;
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   482
      break;
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   483
    case Op_AddL:
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   484
      assert(bt == T_LONG, "must be");
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   485
      vopc = Op_AddReductionVL;
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   486
      break;
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   487
    case Op_AddF:
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   488
      assert(bt == T_FLOAT, "must be");
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   489
      vopc = Op_AddReductionVF;
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   490
      break;
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   491
    case Op_AddD:
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   492
      assert(bt == T_DOUBLE, "must be");
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   493
      vopc = Op_AddReductionVD;
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   494
      break;
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   495
    case Op_MulI:
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   496
      assert(bt == T_INT, "must be");
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   497
      vopc = Op_MulReductionVI;
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   498
      break;
30624
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30211
diff changeset
   499
    case Op_MulL:
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30211
diff changeset
   500
      assert(bt == T_LONG, "must be");
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30211
diff changeset
   501
      vopc = Op_MulReductionVL;
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30211
diff changeset
   502
      break;
30211
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   503
    case Op_MulF:
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   504
      assert(bt == T_FLOAT, "must be");
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   505
      vopc = Op_MulReductionVF;
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   506
      break;
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   507
    case Op_MulD:
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   508
      assert(bt == T_DOUBLE, "must be");
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   509
      vopc = Op_MulReductionVD;
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   510
      break;
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   511
    // TODO: add MulL for targets that support it
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   512
    default:
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   513
      break;
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   514
  }
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   515
  return vopc;
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   516
}
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   517
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   518
// Return the appropriate reduction node.
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   519
ReductionNode* ReductionNode::make(int opc, Node *ctrl, Node* n1, Node* n2, BasicType bt) {
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   520
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   521
  int vopc = opcode(opc, bt);
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   522
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   523
  // This method should not be called for unimplemented vectors.
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32723
diff changeset
   524
  guarantee(vopc != opc, "Vector for '%s' is not implemented", NodeClassNames[opc]);
30211
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   525
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   526
  switch (vopc) {
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   527
  case Op_AddReductionVI: return new AddReductionVINode(ctrl, n1, n2);
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   528
  case Op_AddReductionVL: return new AddReductionVLNode(ctrl, n1, n2);
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   529
  case Op_AddReductionVF: return new AddReductionVFNode(ctrl, n1, n2);
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   530
  case Op_AddReductionVD: return new AddReductionVDNode(ctrl, n1, n2);
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   531
  case Op_MulReductionVI: return new MulReductionVINode(ctrl, n1, n2);
30624
2e1803c8a26d 8076276: Add support for AVX512
kvn
parents: 30211
diff changeset
   532
  case Op_MulReductionVL: return new MulReductionVLNode(ctrl, n1, n2);
30211
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   533
  case Op_MulReductionVF: return new MulReductionVFNode(ctrl, n1, n2);
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   534
  case Op_MulReductionVD: return new MulReductionVDNode(ctrl, n1, n2);
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   535
  }
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32723
diff changeset
   536
  fatal("Missed vector creation for '%s'", NodeClassNames[vopc]);
30211
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   537
  return NULL;
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   538
}
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   539
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   540
bool ReductionNode::implemented(int opc, uint vlen, BasicType bt) {
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   541
  if (is_java_primitive(bt) &&
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   542
      (vlen > 1) && is_power_of_2(vlen) &&
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   543
      Matcher::vector_size_supported(bt, vlen)) {
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   544
    int vopc = ReductionNode::opcode(opc, bt);
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   545
    return vopc != opc && Matcher::match_rule_supported(vopc);
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   546
  }
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   547
  return false;
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   548
}
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 25930
diff changeset
   549