src/hotspot/share/opto/superword.hpp
author coleenp
Thu, 10 Jan 2019 15:13:51 -0500
changeset 53244 9807daeb47c4
parent 52992 4bb6e0871bf7
child 58962 2dcfc28a314d
permissions -rw-r--r--
8216167: Update include guards to reflect correct directories Summary: Use script and some manual fixup to fix directores names in include guards. Reviewed-by: lfoltan, eosterlund, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52992
diff changeset
     2
 * Copyright (c) 2007, 2019, 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: 3261
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
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: 3261
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52992
diff changeset
    24
#ifndef SHARE_OPTO_SUPERWORD_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52992
diff changeset
    25
#define SHARE_OPTO_SUPERWORD_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "opto/loopnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "opto/node.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "opto/phaseX.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "opto/vectornode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "utilities/growableArray.hpp"
33469
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
    32
#include "libadt/dict.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
//                  S U P E R W O R D   T R A N S F O R M
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// SuperWords are short, fixed length vectors.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// Algorithm from:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
// Exploiting SuperWord Level Parallelism with
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
//   Multimedia Instruction Sets
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
// by
30625
80a08f9b2d63 8078497: C2's superword optimization causes unaligned memory accesses
thartmann
parents: 30593
diff changeset
    44
//   Samuel Larsen and Saman Amarasinghe
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
//   MIT Laboratory for Computer Science
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
// date
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
//   May 2000
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
// published in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
//   ACM SIGPLAN Notices
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
//   Proceedings of ACM PLDI '00,  Volume 35 Issue 5
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
// Definition 3.1 A Pack is an n-tuple, <s1, ...,sn>, where
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
// s1,...,sn are independent isomorphic statements in a basic
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
// block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
// Definition 3.2 A PackSet is a set of Packs.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
// Definition 3.3 A Pair is a Pack of size two, where the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
// first statement is considered the left element, and the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
// second statement is considered the right element.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
class SWPointer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
class OrderedPair;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
// ========================= Dependence Graph =====================
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
class DepMem;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
//------------------------------DepEdge---------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
// An edge in the dependence graph.  The edges incident to a dependence
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
// node are threaded through _next_in for incoming edges and _next_out
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
// for outgoing edges.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
class DepEdge : public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  DepMem* _pred;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  DepMem* _succ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  DepEdge* _next_in;   // list of in edges, null terminated
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  DepEdge* _next_out;  // list of out edges, null terminated
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  DepEdge(DepMem* pred, DepMem* succ, DepEdge* next_in, DepEdge* next_out) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    _pred(pred), _succ(succ), _next_in(next_in), _next_out(next_out) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  DepEdge* next_in()  { return _next_in; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  DepEdge* next_out() { return _next_out; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  DepMem*  pred()     { return _pred; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  DepMem*  succ()     { return _succ; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  void print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
//------------------------------DepMem---------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
// A node in the dependence graph.  _in_head starts the threaded list of
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
// incoming edges, and _out_head starts the list of outgoing edges.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
class DepMem : public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  Node*    _node;     // Corresponding ideal node
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  DepEdge* _in_head;  // Head of list of in edges, null terminated
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  DepEdge* _out_head; // Head of list of out edges, null terminated
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  DepMem(Node* node) : _node(node), _in_head(NULL), _out_head(NULL) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  Node*    node()                { return _node;     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  DepEdge* in_head()             { return _in_head;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  DepEdge* out_head()            { return _out_head; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  void set_in_head(DepEdge* hd)  { _in_head = hd;    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  void set_out_head(DepEdge* hd) { _out_head = hd;   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  int in_cnt();  // Incoming edge count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  int out_cnt(); // Outgoing edge count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  void print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
//------------------------------DepGraph---------------------------
49373
47b5652f2928 8199283: Remove ValueObj class for allocation subclassing for compiler code
coleenp
parents: 48136
diff changeset
   117
class DepGraph {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  Arena* _arena;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  GrowableArray<DepMem*> _map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  DepMem* _root;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  DepMem* _tail;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  DepGraph(Arena* a) : _arena(a), _map(a, 8,  0, NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    _root = new (_arena) DepMem(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    _tail = new (_arena) DepMem(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  DepMem* root() { return _root; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  DepMem* tail() { return _tail; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  // Return dependence node corresponding to an ideal node
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  DepMem* dep(Node* node) { return _map.at(node->_idx); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  // Make a new dependence graph node for an ideal node.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  DepMem* make_node(Node* node);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // Make a new dependence graph edge dprec->dsucc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  DepEdge* make_edge(DepMem* dpred, DepMem* dsucc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  DepEdge* make_edge(Node* pred,   Node* succ)   { return make_edge(dep(pred), dep(succ)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  DepEdge* make_edge(DepMem* pred, Node* succ)   { return make_edge(pred,      dep(succ)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  DepEdge* make_edge(Node* pred,   DepMem* succ) { return make_edge(dep(pred), succ);      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  void init() { _map.clear(); } // initialize
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  void print(Node* n)   { dep(n)->print(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  void print(DepMem* d) { d->print(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
//------------------------------DepPreds---------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
// Iterator over predecessors in the dependence graph and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
// non-memory-graph inputs of ideal nodes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
class DepPreds : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  Node*    _n;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  int      _next_idx, _end_idx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  DepEdge* _dep_next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  Node*    _current;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  bool     _done;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  DepPreds(Node* n, DepGraph& dg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  Node* current() { return _current; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  bool  done()    { return _done; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  void  next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
//------------------------------DepSuccs---------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
// Iterator over successors in the dependence graph and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
// non-memory-graph outputs of ideal nodes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
class DepSuccs : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  Node*    _n;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  int      _next_idx, _end_idx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  DepEdge* _dep_next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  Node*    _current;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  bool     _done;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  DepSuccs(Node* n, DepGraph& dg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  Node* current() { return _current; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  bool  done()    { return _done; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  void  next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
// ========================= SuperWord =====================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
// -----------------------------SWNodeInfo---------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
// Per node info needed by SuperWord
49373
47b5652f2928 8199283: Remove ValueObj class for allocation subclassing for compiler code
coleenp
parents: 48136
diff changeset
   193
class SWNodeInfo {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  int         _alignment; // memory alignment for a node
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  int         _depth;     // Max expression (DAG) depth from block start
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  const Type* _velt_type; // vector element type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  Node_List*  _my_pack;   // pack containing this node
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  SWNodeInfo() : _alignment(-1), _depth(0), _velt_type(NULL), _my_pack(NULL) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  static const SWNodeInfo initial;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
33469
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   204
class SuperWord;
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   205
class CMoveKit {
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   206
 friend class SuperWord;
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   207
 private:
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   208
  SuperWord* _sw;
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   209
  Dict* _dict;
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   210
  CMoveKit(Arena* a, SuperWord* sw) : _sw(sw)  {_dict = new Dict(cmpkey, hashkey, a);}
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   211
  void*     _2p(Node* key)        const  { return (void*)(intptr_t)key; } // 2 conversion functions to make gcc happy
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   212
  Dict*     dict()                const  { return _dict; }
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   213
  void map(Node* key, Node_List* val)    { assert(_dict->operator[](_2p(key)) == NULL, "key existed"); _dict->Insert(_2p(key), (void*)val); }
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   214
  void unmap(Node* key)                  { _dict->Delete(_2p(key)); }
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   215
  Node_List* pack(Node* key)      const  { return (Node_List*)_dict->operator[](_2p(key)); }
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   216
  Node* is_Bool_candidate(Node* nd) const; // if it is the right candidate return corresponding CMove* ,
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   217
  Node* is_CmpD_candidate(Node* nd) const; // otherwise return NULL
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   218
  Node_List* make_cmovevd_pack(Node_List* cmovd_pk);
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   219
  bool test_cmpd_pack(Node_List* cmpd_pk, Node_List* cmovd_pk);
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   220
};//class CMoveKit
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   221
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   222
// JVMCI: OrderedPair is moved up to deal with compilation issues on Windows
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   223
//------------------------------OrderedPair---------------------------
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   224
// Ordered pair of Node*.
49373
47b5652f2928 8199283: Remove ValueObj class for allocation subclassing for compiler code
coleenp
parents: 48136
diff changeset
   225
class OrderedPair {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   226
 protected:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   227
  Node* _p1;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   228
  Node* _p2;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   229
 public:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   230
  OrderedPair() : _p1(NULL), _p2(NULL) {}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   231
  OrderedPair(Node* p1, Node* p2) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   232
    if (p1->_idx < p2->_idx) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   233
      _p1 = p1; _p2 = p2;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   234
    } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   235
      _p1 = p2; _p2 = p1;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   236
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   237
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   238
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   239
  bool operator==(const OrderedPair &rhs) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   240
    return _p1 == rhs._p1 && _p2 == rhs._p2;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   241
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   242
  void print() { tty->print("  (%d, %d)", _p1->_idx, _p2->_idx); }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   243
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   244
  static const OrderedPair initial;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   245
};
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 31858
diff changeset
   246
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
// -----------------------------SuperWord---------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
// Transforms scalar operations into packed (superword) operations.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
class SuperWord : public ResourceObj {
31858
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   250
 friend class SWPointer;
33469
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   251
 friend class CMoveKit;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  PhaseIdealLoop* _phase;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  Arena*          _arena;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  PhaseIterGVN   &_igvn;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  enum consts { top_align = -1, bottom_align = -666 };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  GrowableArray<Node_List*> _packset;    // Packs for the current block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  GrowableArray<int> _bb_idx;            // Map from Node _idx to index within block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  GrowableArray<Node*> _block;           // Nodes in current block
38049
e8541793960f 8153998: Masked vector post loops
mcberg
parents: 33469
diff changeset
   264
  GrowableArray<Node*> _post_block;      // Nodes in post loop block
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  GrowableArray<Node*> _data_entry;      // Nodes with all inputs from outside
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  GrowableArray<Node*> _mem_slice_head;  // Memory slice head nodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  GrowableArray<Node*> _mem_slice_tail;  // Memory slice tail nodes
30593
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   268
  GrowableArray<Node*> _iteration_first; // nodes in the generation that has deps from phi
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   269
  GrowableArray<Node*> _iteration_last;  // nodes in the generation that has deps to   phi
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  GrowableArray<SWNodeInfo> _node_info;  // Info needed per node
33469
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   271
  CloneMap&            _clone_map;       // map of nodes created in cloning
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   272
  CMoveKit             _cmovev_kit;      // support for vectorization of CMov
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  MemNode* _align_to_ref;                // Memory reference that pre-loop will align to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  GrowableArray<OrderedPair> _disjoint_ptrs; // runtime disambiguated pointer pairs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  DepGraph _dg; // Dependence graph
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  // Scratch pads
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  VectorSet    _visited;       // Visited set
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  VectorSet    _post_visited;  // Post-visited set
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  Node_Stack   _n_idx_list;    // List of (node,index) pairs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  GrowableArray<Node*> _nlist; // List of nodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  GrowableArray<Node*> _stk;   // Stack of nodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  SuperWord(PhaseIdealLoop* phase);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
31403
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   289
  void transform_loop(IdealLoopTree* lpt, bool do_optimization);
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   290
31772
718fc367468d 8129920: Vectorized loop unrolling
kvn
parents: 31403
diff changeset
   291
  void unrolling_analysis(int &local_loop_unroll_factor);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  // Accessors for SWPointer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  PhaseIdealLoop* phase()          { return _phase; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  IdealLoopTree* lpt()             { return _lpt; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  PhiNode* iv()                    { return _iv; }
31858
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   297
31403
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   298
  bool early_return()              { return _early_return; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
31858
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   300
#ifndef PRODUCT
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   301
  bool     is_debug()              { return _vector_loop_debug > 0; }
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   302
  bool     is_trace_alignment()    { return (_vector_loop_debug & 2) > 0; }
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   303
  bool     is_trace_mem_slice()    { return (_vector_loop_debug & 4) > 0; }
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   304
  bool     is_trace_loop()         { return (_vector_loop_debug & 8) > 0; }
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   305
  bool     is_trace_adjacent()     { return (_vector_loop_debug & 16) > 0; }
33469
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   306
  bool     is_trace_cmov()         { return (_vector_loop_debug & 32) > 0; }
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   307
  bool     is_trace_loop_reverse() { return (_vector_loop_debug & 64) > 0; }
31858
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   308
#endif
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   309
  bool     do_vector_loop()        { return _do_vector_loop; }
33469
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   310
  bool     do_reserve_copy()       { return _do_reserve_copy; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  IdealLoopTree* _lpt;             // Current loop tree node
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  LoopNode*      _lp;              // Current LoopNode
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  Node*          _bb;              // Current basic block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  PhiNode*       _iv;              // Induction var
30211
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 23528
diff changeset
   316
  bool           _race_possible;   // In cases where SDMU is true
31403
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   317
  bool           _early_return;    // True if we do not initialize
30593
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   318
  bool           _do_vector_loop;  // whether to do vectorization/simd style
33469
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   319
  bool           _do_reserve_copy; // do reserve copy of the graph(loop) before final modification in output
30588
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents: 30211
diff changeset
   320
  int            _num_work_vecs;   // Number of non memory vector operations
24fc4b3a964e 8078563: Restrict reduction optimization
kvn
parents: 30211
diff changeset
   321
  int            _num_reductions;  // Number of reduction expressions applied
30593
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   322
  int            _ii_first;        // generation with direct deps from mem phi
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   323
  int            _ii_last;         // generation with direct deps to   mem phi
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   324
  GrowableArray<int> _ii_order;
31858
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   325
#ifndef PRODUCT
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   326
  uintx          _vector_loop_debug; // provide more printing in debug mode
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   327
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  // Accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  Arena* arena()                   { return _arena; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  Node* bb()                       { return _bb; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  void  set_bb(Node* bb)           { _bb = bb; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  void set_lpt(IdealLoopTree* lpt) { _lpt = lpt; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  LoopNode* lp()                   { return _lp; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  void      set_lp(LoopNode* lp)   { _lp = lp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
                                     _iv = lp->as_CountedLoop()->phi()->as_Phi(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  int      iv_stride()             { return lp()->as_CountedLoop()->stride_con(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
13108
6d27f658925c 7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents: 13104
diff changeset
   342
  int vector_width(Node* n) {
6d27f658925c 7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents: 13104
diff changeset
   343
    BasicType bt = velt_basic_type(n);
6d27f658925c 7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents: 13104
diff changeset
   344
    return MIN2(ABS(iv_stride()), Matcher::max_vector_size(bt));
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   345
  }
13108
6d27f658925c 7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents: 13104
diff changeset
   346
  int vector_width_in_bytes(Node* n) {
6d27f658925c 7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents: 13104
diff changeset
   347
    BasicType bt = velt_basic_type(n);
6d27f658925c 7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents: 13104
diff changeset
   348
    return vector_width(n)*type2aelembytes(bt);
6d27f658925c 7177923: SIGBUS on sparc in compiled code for java.util.Calendar.clear()
kvn
parents: 13104
diff changeset
   349
  }
52992
4bb6e0871bf7 8214751: X86: Support for VNNI Instructions
vdeshpande
parents: 49373
diff changeset
   350
  int get_vw_bytes_special(MemNode* s);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  MemNode* align_to_ref()            { return _align_to_ref; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  void  set_align_to_ref(MemNode* m) { _align_to_ref = m; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  Node* ctrl(Node* n) const { return _phase->has_ctrl(n) ? _phase->get_ctrl(n) : n; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  // block accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  bool in_bb(Node* n)      { return n != NULL && n->outcnt() > 0 && ctrl(n) == _bb; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  int  bb_idx(Node* n)     { assert(in_bb(n), "must be"); return _bb_idx.at(n->_idx); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  void set_bb_idx(Node* n, int i) { _bb_idx.at_put_grow(n->_idx, i); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  // visited set accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  void visited_clear()           { _visited.Clear(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  void visited_set(Node* n)      { return _visited.set(bb_idx(n)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  int visited_test(Node* n)      { return _visited.test(bb_idx(n)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
  int visited_test_set(Node* n)  { return _visited.test_set(bb_idx(n)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  void post_visited_clear()      { _post_visited.Clear(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  void post_visited_set(Node* n) { return _post_visited.set(bb_idx(n)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  int post_visited_test(Node* n) { return _post_visited.test(bb_idx(n)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  // Ensure node_info contains element "i"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  void grow_node_info(int i) { if (i >= _node_info.length()) _node_info.at_put_grow(i, SWNodeInfo::initial); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  // memory alignment for a node
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  int alignment(Node* n)                     { return _node_info.adr_at(bb_idx(n))->_alignment; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  void set_alignment(Node* n, int a)         { int i = bb_idx(n); grow_node_info(i); _node_info.adr_at(i)->_alignment = a; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  // Max expression (DAG) depth from beginning of the block for each node
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  int depth(Node* n)                         { return _node_info.adr_at(bb_idx(n))->_depth; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  void set_depth(Node* n, int d)             { int i = bb_idx(n); grow_node_info(i); _node_info.adr_at(i)->_depth = d; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  // vector element type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  const Type* velt_type(Node* n)             { return _node_info.adr_at(bb_idx(n))->_velt_type; }
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   383
  BasicType velt_basic_type(Node* n)         { return velt_type(n)->array_element_basic_type(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  void set_velt_type(Node* n, const Type* t) { int i = bb_idx(n); grow_node_info(i); _node_info.adr_at(i)->_velt_type = t; }
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   385
  bool same_velt_type(Node* n1, Node* n2);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
  // my_pack
33469
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   388
  Node_List* my_pack(Node* n)                 { return !in_bb(n) ? NULL : _node_info.adr_at(bb_idx(n))->_my_pack; }
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   389
  void set_my_pack(Node* n, Node_List* p)     { int i = bb_idx(n); grow_node_info(i); _node_info.adr_at(i)->_my_pack = p; }
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   390
  // is pack good for converting into one vector node replacing 12 nodes of Cmp, Bool, CMov
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   391
  bool is_cmov_pack(Node_List* p);
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   392
  bool is_cmov_pack_internal_node(Node_List* p, Node* nd) { return is_cmov_pack(p) && !nd->is_CMove(); }
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   393
  // For pack p, are all idx operands the same?
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   394
  bool same_inputs(Node_List* p, int idx);
31858
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   395
  // CloneMap utilities
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   396
  bool same_origin_idx(Node* a, Node* b) const;
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   397
  bool same_generation(Node* a, Node* b) const;
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   398
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  // methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  // Extract the superword level parallelism
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  void SLP_extract();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  // Find the adjacent memory references and create pack pairs for them.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  void find_adjacent_refs();
31858
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   405
  // Tracing support
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   406
  #ifndef PRODUCT
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   407
  void find_adjacent_refs_trace_1(Node* best_align_to_mem_ref, int best_iv_adjustment);
33166
81352250770f 8136725: Provide utility for creation a counted loop reserve copy (clone)
iveresov
parents: 33160
diff changeset
   408
  void print_loop(bool whole);
31858
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   409
  #endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  // Find a memory reference to align the loop induction variable to.
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   411
  MemNode* find_align_to_ref(Node_List &memops);
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   412
  // Calculate loop's iv adjustment for this memory ops.
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   413
  int get_iv_adjustment(MemNode* mem);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  // Can the preloop align the reference to position zero in the vector?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  bool ref_is_alignable(SWPointer& p);
30593
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   416
  // rebuild the graph so all loads in different iterations of cloned loop become dependant on phi node (in _do_vector_loop only)
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   417
  bool hoist_loads_in_graph();
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   418
  // Test whether MemNode::Memory dependency to the same load but in the first iteration of this loop is coming from memory phi
31858
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   419
  // Return false if failed
30593
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   420
  Node* find_phi_for_mem_dep(LoadNode* ld);
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   421
  // Return same node but from the first generation. Return 0, if not found
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   422
  Node* first_node(Node* nd);
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   423
  // Return same node as this but from the last generation. Return 0, if not found
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   424
  Node* last_node(Node* n);
31858
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   425
  // Mark nodes belonging to first and last generation
30593
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   426
  // returns first generation index or -1 if vectorization/simd is impossible
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   427
  int mark_generations();
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   428
  // swapping inputs of commutative instruction (Add or Mul)
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   429
  bool fix_commutative_inputs(Node* gold, Node* fix);
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   430
  // make packs forcefully (in _do_vector_loop only)
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   431
  bool pack_parallel();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  // Construct dependency graph.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  void dependence_graph();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  // Return a memory slice (node list) in predecessor order starting at "start"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  void mem_slice_preds(Node* start, Node* stop, GrowableArray<Node*> &preds);
2131
98f9cef66a34 6810672: Comment typos
twisti
parents: 1
diff changeset
   436
  // Can s1 and s2 be in a pack with s1 immediately preceding s2 and  s1 aligned at "align"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  bool stmts_can_pack(Node* s1, Node* s2, int align);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  // Does s exist in a pack at position pos?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
  bool exists_at(Node* s, uint pos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  // Is s1 immediately before s2 in memory?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  bool are_adjacent_refs(Node* s1, Node* s2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  // Are s1 and s2 similar?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  bool isomorphic(Node* s1, Node* s2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
  // Is there no data path from s1 to s2 or s2 to s1?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  bool independent(Node* s1, Node* s2);
48136
c035fbb1beb4 8181633: Vectorization fails for some multiplication with constant cases
njian
parents: 47216
diff changeset
   446
  // For a node pair (s1, s2) which is isomorphic and independent,
c035fbb1beb4 8181633: Vectorization fails for some multiplication with constant cases
njian
parents: 47216
diff changeset
   447
  // do s1 and s2 have similar input edges?
c035fbb1beb4 8181633: Vectorization fails for some multiplication with constant cases
njian
parents: 47216
diff changeset
   448
  bool have_similar_inputs(Node* s1, Node* s2);
30211
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 23528
diff changeset
   449
  // Is there a data path between s1 and s2 and both are reductions?
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 23528
diff changeset
   450
  bool reduction(Node* s1, Node* s2);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  // Helper for independent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  bool independent_path(Node* shallow, Node* deep, uint dp=0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  void set_alignment(Node* s1, Node* s2, int align);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
  int data_size(Node* s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  // Extend packset by following use->def and def->use links from pack members.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  void extend_packlist();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  // Extend the packset by visiting operand definitions of nodes in pack p
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  bool follow_use_defs(Node_List* p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  // Extend the packset by visiting uses of nodes in pack p
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  bool follow_def_uses(Node_List* p);
30211
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 23528
diff changeset
   461
  // For extended packsets, ordinally arrange uses packset by major component
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 23528
diff changeset
   462
  void order_def_uses(Node_List* p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  // Estimate the savings from executing s1 and s2 as a pack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  int est_savings(Node* s1, Node* s2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  int adjacent_profit(Node* s1, Node* s2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  int pack_cost(int ct);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  int unpack_cost(int ct);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  // Combine packs A and B with A.last == B.first into A.first..,A.last,B.second,..B.last
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  void combine_packs();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  // Construct the map from nodes to packs.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  void construct_my_pack_map();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  // Remove packs that are not implemented or not profitable.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  void filter_packs();
33469
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   474
  // Merge CMoveD into new vector-nodes
30f4811eded0 8139340: SuperWord enhancement to support vector conditional move (CMovVD) on Intel AVX cpu
iveresov
parents: 33166
diff changeset
   475
  void merge_packs_to_cmovd();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  // Adjust the memory graph for the packed operations
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
  void schedule();
2334
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents: 2131
diff changeset
   478
  // Remove "current" from its current position in the memory graph and insert
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents: 2131
diff changeset
   479
  // it after the appropriate insert points (lip or uip);
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents: 2131
diff changeset
   480
  void remove_and_insert(MemNode *current, MemNode *prev, MemNode *lip, Node *uip, Unique_Node_List &schd_before);
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents: 2131
diff changeset
   481
  // Within a store pack, schedule stores together by moving out the sandwiched memory ops according
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents: 2131
diff changeset
   482
  // to dependence info; and within a load pack, move loads down to the last executed load.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  void co_locate_pack(Node_List* p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  // Convert packs into vector node operations
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  void output();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
  // Create a vector operand for the nodes in pack p for operand: in(opd_idx)
10255
bab46e6f7661 7069452: Cleanup NodeFlags
kvn
parents: 7397
diff changeset
   487
  Node* vector_opd(Node_List* p, int opd_idx);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  // Can code be generated for pack p?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  bool implemented(Node_List* p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  // For pack p, are all operands and all uses (with in the block) vector?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  bool profitable(Node_List* p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  // If a use of pack p is not a vector use, then replace the use with an extract operation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  void insert_extracts(Node_List* p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  // Is use->in(u_idx) a vector use?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
  bool is_vector_use(Node* use, int u_idx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
  // Construct reverse postorder list of block members
15755
c54cbfb4b37f 8004867: VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
kvn
parents: 13885
diff changeset
   497
  bool construct_bb();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
  // Initialize per node info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
  void initialize_bb();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
  // Insert n into block after pos
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  void bb_insert_after(Node* n, int pos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  // Compute max depth for expressions from beginning of block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
  void compute_max_depth();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
  // Compute necessary vector element type for expressions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
  void compute_vector_element_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
  // Are s1 and s2 in a pack pair and ordered as s1,s2?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
  bool in_packset(Node* s1, Node* s2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  // Is s in pack p?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  Node_List* in_pack(Node* s, Node_List* p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
  // Remove the pack at position pos in the packset
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
  void remove_pack_at(int pos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
  // Return the node executed first in pack p.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
  Node* executed_first(Node_List* p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
  // Return the node executed last in pack p.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
  Node* executed_last(Node_List* p);
31035
0f0743952c41 8077504: Unsafe load can loose control dependency and cause crash
roland
parents: 30625
diff changeset
   516
  static LoadNode::ControlDependency control_dependency(Node_List* p);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
  // Alignment within a vector memory reference
13885
6b056026ecad 7199010: incorrect vector alignment
kvn
parents: 13108
diff changeset
   518
  int memory_alignment(MemNode* s, int iv_adjust);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
  // (Start, end] half-open range defining which operands are vector
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
  void vector_opd_range(Node* n, uint* start, uint* end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
  // Smallest type containing range of values
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 10255
diff changeset
   522
  const Type* container_type(Node* n);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
  // Adjust pre-loop limit so that in main loop, a load/store reference
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
  // to align_to_ref will be a position zero in the vector.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
  void align_initial_loop_index(MemNode* align_to_ref);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
  // Find pre loop end from main loop.  Returns null if none.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
  CountedLoopEndNode* get_pre_loop_end(CountedLoopNode *cl);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
  // Is the use of d1 in u1 at the same operand position as d2 in u2?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
  bool opnd_positions_match(Node* d1, Node* u1, Node* d2, Node* u2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
  void init();
30593
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   531
  // clean up some basic structures - used if the ideal graph was rebuilt
69f942690128 8076284: Improve vectorization of parallel streams
kvn
parents: 30588
diff changeset
   532
  void restart();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
  // print methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
  void print_packset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
  void print_pack(Node_List* p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  void print_bb();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
  void print_stmt(Node* s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
  char* blank(uint depth);
30211
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 23528
diff changeset
   540
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 23528
diff changeset
   541
  void packset_sort(int n);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
30211
442fbbb31f75 8074981: Integer/FP scalar reduction optimization
kvn
parents: 23528
diff changeset
   545
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
//------------------------------SWPointer---------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
// Information about an address for dependence checking and vector alignment
49373
47b5652f2928 8199283: Remove ValueObj class for allocation subclassing for compiler code
coleenp
parents: 48136
diff changeset
   548
class SWPointer {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
 protected:
31403
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   550
  MemNode*   _mem;           // My memory reference node
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   551
  SuperWord* _slp;           // SuperWord class
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
31403
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   553
  Node* _base;               // NULL if unsafe nonheap reference
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   554
  Node* _adr;                // address pointer
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   555
  jint  _scale;              // multiplier for iv (in bytes), 0 if no loop iv
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   556
  jint  _offset;             // constant offset (in bytes)
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   557
  Node* _invar;              // invariant offset (in bytes), NULL if none
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   558
  bool  _negate_invar;       // if true then use: (0 - _invar)
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   559
  Node_Stack* _nstack;       // stack used to record a swpointer trace of variants
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   560
  bool        _analyze_only; // Used in loop unrolling only for swpointer trace
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   561
  uint        _stack_idx;    // Used in loop unrolling only for swpointer trace
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
  PhaseIdealLoop* phase() { return _slp->phase(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
  IdealLoopTree*  lpt()   { return _slp->lpt(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
  PhiNode*        iv()    { return _slp->iv();  } // Induction var
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
31858
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   567
  bool invariant(Node* n);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
  // Match: k*iv + offset
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
  bool scaled_iv_plus_offset(Node* n);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
  // Match: k*iv where k is a constant that's not zero
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
  bool scaled_iv(Node* n);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
  // Match: offset is (k [+/- invariant])
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
  bool offset_plus_k(Node* n, bool negate = false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
  enum CMP {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
    Less          = 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
    Greater       = 2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
    Equal         = 4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
    NotEqual      = (Less | Greater),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
    NotComparable = (Less | Greater | Equal)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
31403
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   585
  SWPointer(MemNode* mem, SuperWord* slp, Node_Stack *nstack, bool analyze_only);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
  // Following is used to create a temporary object during
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
  // the pattern match of an address expression.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
  SWPointer(SWPointer* p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
  bool valid()  { return _adr != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  bool has_iv() { return _scale != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
31403
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   593
  Node* base()             { return _base; }
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   594
  Node* adr()              { return _adr; }
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   595
  MemNode* mem()           { return _mem; }
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   596
  int   scale_in_bytes()   { return _scale; }
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   597
  Node* invar()            { return _invar; }
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   598
  bool  negate_invar()     { return _negate_invar; }
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   599
  int   offset_in_bytes()  { return _offset; }
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   600
  int   memory_size()      { return _mem->memory_size(); }
7bf7e00a1aac 8080325: SuperWord loop unrolling analysis
mcberg
parents: 31035
diff changeset
   601
  Node_Stack* node_stack() { return _nstack; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
  // Comparable?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
  int cmp(SWPointer& q) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
    if (valid() && q.valid() &&
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 38049
diff changeset
   606
        (_adr == q._adr || (_base == _adr && q._base == q._adr)) &&
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
        _scale == q._scale   &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
        _invar == q._invar   &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
        _negate_invar == q._negate_invar) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
      bool overlap = q._offset <   _offset +   memory_size() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
                       _offset < q._offset + q.memory_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
      return overlap ? Equal : (_offset < q._offset ? Less : Greater);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
      return NotComparable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
  bool not_equal(SWPointer& q)    { return not_equal(cmp(q)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
  bool equal(SWPointer& q)        { return equal(cmp(q)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
  bool comparable(SWPointer& q)   { return comparable(cmp(q)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
  static bool not_equal(int cmp)  { return cmp <= NotEqual; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
  static bool equal(int cmp)      { return cmp == Equal; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
  static bool comparable(int cmp) { return cmp < NotComparable; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
  void print();
31858
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   626
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   627
#ifndef PRODUCT
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   628
  class Tracer {
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   629
    friend class SuperWord;
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   630
    friend class SWPointer;
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   631
    SuperWord*   _slp;
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   632
    static int   _depth;
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   633
    int _depth_save;
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   634
    void print_depth();
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   635
    int  depth() const    { return _depth; }
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   636
    void set_depth(int d) { _depth = d; }
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   637
    void inc_depth()      { _depth++;}
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   638
    void dec_depth()      { if (_depth > 0) _depth--;}
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   639
    void store_depth()    {_depth_save = _depth;}
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   640
    void restore_depth()  {_depth = _depth_save;}
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   641
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   642
    class Depth {
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   643
      friend class Tracer;
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   644
      friend class SWPointer;
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   645
      friend class SuperWord;
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   646
      Depth()  { ++_depth; }
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   647
      Depth(int x)  { _depth = 0; }
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   648
      ~Depth() { if (_depth > 0) --_depth;}
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   649
    };
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   650
    Tracer (SuperWord* slp) : _slp(slp) {}
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   651
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   652
    // tracing functions
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   653
    void ctor_1(Node* mem);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   654
    void ctor_2(Node* adr);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   655
    void ctor_3(Node* adr, int i);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   656
    void ctor_4(Node* adr, int i);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   657
    void ctor_5(Node* adr, Node* base,  int i);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   658
    void ctor_6(Node* mem);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   659
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   660
    void invariant_1(Node *n, Node *n_c);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   661
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   662
    void scaled_iv_plus_offset_1(Node* n);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   663
    void scaled_iv_plus_offset_2(Node* n);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   664
    void scaled_iv_plus_offset_3(Node* n);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   665
    void scaled_iv_plus_offset_4(Node* n);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   666
    void scaled_iv_plus_offset_5(Node* n);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   667
    void scaled_iv_plus_offset_6(Node* n);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   668
    void scaled_iv_plus_offset_7(Node* n);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   669
    void scaled_iv_plus_offset_8(Node* n);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   670
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   671
    void scaled_iv_1(Node* n);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   672
    void scaled_iv_2(Node* n, int scale);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   673
    void scaled_iv_3(Node* n, int scale);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   674
    void scaled_iv_4(Node* n, int scale);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   675
    void scaled_iv_5(Node* n, int scale);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   676
    void scaled_iv_6(Node* n, int scale);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   677
    void scaled_iv_7(Node* n);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   678
    void scaled_iv_8(Node* n, SWPointer* tmp);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   679
    void scaled_iv_9(Node* n, int _scale, int _offset, int mult);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   680
    void scaled_iv_10(Node* n);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   681
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   682
    void offset_plus_k_1(Node* n);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   683
    void offset_plus_k_2(Node* n, int _offset);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   684
    void offset_plus_k_3(Node* n, int _offset);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   685
    void offset_plus_k_4(Node* n);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   686
    void offset_plus_k_5(Node* n, Node* _invar);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   687
    void offset_plus_k_6(Node* n, Node* _invar, bool _negate_invar, int _offset);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   688
    void offset_plus_k_7(Node* n, Node* _invar, bool _negate_invar, int _offset);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   689
    void offset_plus_k_8(Node* n, Node* _invar, bool _negate_invar, int _offset);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   690
    void offset_plus_k_9(Node* n, Node* _invar, bool _negate_invar, int _offset);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   691
    void offset_plus_k_10(Node* n, Node* _invar, bool _negate_invar, int _offset);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   692
    void offset_plus_k_11(Node* n);
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   693
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   694
  } _tracer;//TRacer;
13420c0a3ad5 8085932: Fixing bugs in detecting memory alignments in SuperWord
kvn
parents: 31772
diff changeset
   695
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52992
diff changeset
   698
#endif // SHARE_OPTO_SUPERWORD_HPP