2017-09-13 23:43:53 +02:00
|
|
|
//===- GVNExpression.h - GVN Expression classes -----------------*- C++ -*-===//
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2017-09-13 23:43:53 +02:00
|
|
|
//
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
/// \file
|
|
|
|
///
|
|
|
|
/// The header file for the GVN pass that contains expression handling
|
|
|
|
/// classes
|
2017-09-13 23:43:53 +02:00
|
|
|
//
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_TRANSFORMS_SCALAR_GVNEXPRESSION_H
|
|
|
|
#define LLVM_TRANSFORMS_SCALAR_GVNEXPRESSION_H
|
|
|
|
|
|
|
|
#include "llvm/ADT/Hashing.h"
|
2017-01-18 01:57:48 +01:00
|
|
|
#include "llvm/ADT/iterator_range.h"
|
2017-04-11 22:06:36 +02:00
|
|
|
#include "llvm/Analysis/MemorySSA.h"
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
#include "llvm/IR/Constant.h"
|
|
|
|
#include "llvm/IR/Instructions.h"
|
|
|
|
#include "llvm/IR/Value.h"
|
|
|
|
#include "llvm/Support/Allocator.h"
|
|
|
|
#include "llvm/Support/ArrayRecycler.h"
|
2017-01-18 01:57:48 +01:00
|
|
|
#include "llvm/Support/Casting.h"
|
2017-09-13 23:43:53 +02:00
|
|
|
#include "llvm/Support/Compiler.h"
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
#include <algorithm>
|
2017-01-18 01:57:48 +01:00
|
|
|
#include <cassert>
|
|
|
|
#include <iterator>
|
|
|
|
#include <utility>
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2017-09-13 23:43:53 +02:00
|
|
|
class BasicBlock;
|
|
|
|
class Type;
|
|
|
|
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
namespace GVNExpression {
|
|
|
|
|
|
|
|
enum ExpressionType {
|
|
|
|
ET_Base,
|
|
|
|
ET_Constant,
|
|
|
|
ET_Variable,
|
2017-05-19 22:22:20 +02:00
|
|
|
ET_Dead,
|
2017-01-02 19:00:53 +01:00
|
|
|
ET_Unknown,
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
ET_BasicStart,
|
|
|
|
ET_Basic,
|
|
|
|
ET_AggregateValue,
|
|
|
|
ET_Phi,
|
2017-04-01 11:44:29 +02:00
|
|
|
ET_MemoryStart,
|
|
|
|
ET_Call,
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
ET_Load,
|
|
|
|
ET_Store,
|
2017-04-01 11:44:29 +02:00
|
|
|
ET_MemoryEnd,
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
ET_BasicEnd
|
|
|
|
};
|
|
|
|
|
|
|
|
class Expression {
|
|
|
|
private:
|
|
|
|
ExpressionType EType;
|
|
|
|
unsigned Opcode;
|
2017-09-13 23:43:53 +02:00
|
|
|
mutable hash_code HashVal = 0;
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
Expression(ExpressionType ET = ET_Base, unsigned O = ~2U)
|
2017-09-13 23:43:53 +02:00
|
|
|
: EType(ET), Opcode(O) {}
|
2017-01-18 01:57:48 +01:00
|
|
|
Expression(const Expression &) = delete;
|
|
|
|
Expression &operator=(const Expression &) = delete;
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
virtual ~Expression();
|
|
|
|
|
|
|
|
static unsigned getEmptyKey() { return ~0U; }
|
|
|
|
static unsigned getTombstoneKey() { return ~1U; }
|
2017-09-13 23:43:53 +02:00
|
|
|
|
2017-03-18 16:41:40 +01:00
|
|
|
bool operator!=(const Expression &Other) const { return !(*this == Other); }
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
bool operator==(const Expression &Other) const {
|
|
|
|
if (getOpcode() != Other.getOpcode())
|
|
|
|
return false;
|
|
|
|
if (getOpcode() == getEmptyKey() || getOpcode() == getTombstoneKey())
|
|
|
|
return true;
|
|
|
|
// Compare the expression type for anything but load and store.
|
2017-04-06 20:52:50 +02:00
|
|
|
// For load and store we set the opcode to zero to make them equal.
|
2016-12-26 21:06:58 +01:00
|
|
|
if (getExpressionType() != ET_Load && getExpressionType() != ET_Store &&
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
getExpressionType() != Other.getExpressionType())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return equals(Other);
|
|
|
|
}
|
2017-09-13 23:43:53 +02:00
|
|
|
|
2017-05-30 08:58:18 +02:00
|
|
|
hash_code getComputedHash() const {
|
|
|
|
// It's theoretically possible for a thing to hash to zero. In that case,
|
|
|
|
// we will just compute the hash a few extra times, which is no worse that
|
|
|
|
// we did before, which was to compute it always.
|
|
|
|
if (static_cast<unsigned>(HashVal) == 0)
|
|
|
|
HashVal = getHashValue();
|
|
|
|
return HashVal;
|
|
|
|
}
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
|
|
|
virtual bool equals(const Expression &Other) const { return true; }
|
2017-09-13 23:43:53 +02:00
|
|
|
|
2017-06-06 19:15:28 +02:00
|
|
|
// Return true if the two expressions are exactly the same, including the
|
|
|
|
// normally ignored fields.
|
|
|
|
virtual bool exactlyEquals(const Expression &Other) const {
|
|
|
|
return getExpressionType() == Other.getExpressionType() && equals(Other);
|
|
|
|
}
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
|
|
|
unsigned getOpcode() const { return Opcode; }
|
|
|
|
void setOpcode(unsigned opcode) { Opcode = opcode; }
|
|
|
|
ExpressionType getExpressionType() const { return EType; }
|
|
|
|
|
2017-04-01 11:44:29 +02:00
|
|
|
// We deliberately leave the expression type out of the hash value.
|
|
|
|
virtual hash_code getHashValue() const { return getOpcode(); }
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
|
|
|
// Debugging support
|
|
|
|
virtual void printInternal(raw_ostream &OS, bool PrintEType) const {
|
|
|
|
if (PrintEType)
|
|
|
|
OS << "etype = " << getExpressionType() << ",";
|
|
|
|
OS << "opcode = " << getOpcode() << ", ";
|
|
|
|
}
|
|
|
|
|
|
|
|
void print(raw_ostream &OS) const {
|
|
|
|
OS << "{ ";
|
|
|
|
printInternal(OS, true);
|
|
|
|
OS << "}";
|
|
|
|
}
|
2017-01-18 01:57:48 +01:00
|
|
|
|
2017-06-14 21:16:22 +02:00
|
|
|
LLVM_DUMP_METHOD void dump() const;
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
inline raw_ostream &operator<<(raw_ostream &OS, const Expression &E) {
|
|
|
|
E.print(OS);
|
|
|
|
return OS;
|
|
|
|
}
|
|
|
|
|
|
|
|
class BasicExpression : public Expression {
|
|
|
|
private:
|
2017-09-13 23:43:53 +02:00
|
|
|
using RecyclerType = ArrayRecycler<Value *>;
|
|
|
|
using RecyclerCapacity = RecyclerType::Capacity;
|
|
|
|
|
|
|
|
Value **Operands = nullptr;
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
unsigned MaxOperands;
|
2017-09-13 23:43:53 +02:00
|
|
|
unsigned NumOperands = 0;
|
|
|
|
Type *ValueType = nullptr;
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
BasicExpression(unsigned NumOperands)
|
|
|
|
: BasicExpression(NumOperands, ET_Basic) {}
|
|
|
|
BasicExpression(unsigned NumOperands, ExpressionType ET)
|
2017-09-13 23:43:53 +02:00
|
|
|
: Expression(ET), MaxOperands(NumOperands) {}
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
BasicExpression() = delete;
|
2017-01-18 01:57:48 +01:00
|
|
|
BasicExpression(const BasicExpression &) = delete;
|
|
|
|
BasicExpression &operator=(const BasicExpression &) = delete;
|
|
|
|
~BasicExpression() override;
|
|
|
|
|
|
|
|
static bool classof(const Expression *EB) {
|
|
|
|
ExpressionType ET = EB->getExpressionType();
|
|
|
|
return ET > ET_BasicStart && ET < ET_BasicEnd;
|
|
|
|
}
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Swap two operands. Used during GVN to put commutative operands in
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
/// order.
|
|
|
|
void swapOperands(unsigned First, unsigned Second) {
|
|
|
|
std::swap(Operands[First], Operands[Second]);
|
|
|
|
}
|
|
|
|
|
|
|
|
Value *getOperand(unsigned N) const {
|
|
|
|
assert(Operands && "Operands not allocated");
|
|
|
|
assert(N < NumOperands && "Operand out of range");
|
|
|
|
return Operands[N];
|
|
|
|
}
|
|
|
|
|
|
|
|
void setOperand(unsigned N, Value *V) {
|
|
|
|
assert(Operands && "Operands not allocated before setting");
|
|
|
|
assert(N < NumOperands && "Operand out of range");
|
|
|
|
Operands[N] = V;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned getNumOperands() const { return NumOperands; }
|
|
|
|
|
2017-09-13 23:43:53 +02:00
|
|
|
using op_iterator = Value **;
|
|
|
|
using const_op_iterator = Value *const *;
|
|
|
|
|
2016-12-25 23:10:37 +01:00
|
|
|
op_iterator op_begin() { return Operands; }
|
|
|
|
op_iterator op_end() { return Operands + NumOperands; }
|
|
|
|
const_op_iterator op_begin() const { return Operands; }
|
|
|
|
const_op_iterator op_end() const { return Operands + NumOperands; }
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
iterator_range<op_iterator> operands() {
|
2016-12-25 23:10:37 +01:00
|
|
|
return iterator_range<op_iterator>(op_begin(), op_end());
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
}
|
2016-12-25 23:10:37 +01:00
|
|
|
iterator_range<const_op_iterator> operands() const {
|
|
|
|
return iterator_range<const_op_iterator>(op_begin(), op_end());
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
}
|
|
|
|
|
2016-12-25 23:10:37 +01:00
|
|
|
void op_push_back(Value *Arg) {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
assert(NumOperands < MaxOperands && "Tried to add too many operands");
|
|
|
|
assert(Operands && "Operandss not allocated before pushing");
|
|
|
|
Operands[NumOperands++] = Arg;
|
|
|
|
}
|
2016-12-25 23:10:37 +01:00
|
|
|
bool op_empty() const { return getNumOperands() == 0; }
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
|
|
|
void allocateOperands(RecyclerType &Recycler, BumpPtrAllocator &Allocator) {
|
|
|
|
assert(!Operands && "Operands already allocated");
|
|
|
|
Operands = Recycler.allocate(RecyclerCapacity::get(MaxOperands), Allocator);
|
|
|
|
}
|
|
|
|
void deallocateOperands(RecyclerType &Recycler) {
|
|
|
|
Recycler.deallocate(RecyclerCapacity::get(MaxOperands), Operands);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setType(Type *T) { ValueType = T; }
|
|
|
|
Type *getType() const { return ValueType; }
|
|
|
|
|
2017-01-18 01:57:48 +01:00
|
|
|
bool equals(const Expression &Other) const override {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
if (getOpcode() != Other.getOpcode())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
const auto &OE = cast<BasicExpression>(Other);
|
2016-12-24 18:14:19 +01:00
|
|
|
return getType() == OE.getType() && NumOperands == OE.NumOperands &&
|
2016-12-26 21:06:58 +01:00
|
|
|
std::equal(op_begin(), op_end(), OE.op_begin());
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
}
|
|
|
|
|
2017-01-18 01:57:48 +01:00
|
|
|
hash_code getHashValue() const override {
|
2017-04-01 11:44:29 +02:00
|
|
|
return hash_combine(this->Expression::getHashValue(), ValueType,
|
2016-12-25 23:10:37 +01:00
|
|
|
hash_combine_range(op_begin(), op_end()));
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Debugging support
|
2017-01-18 01:57:48 +01:00
|
|
|
void printInternal(raw_ostream &OS, bool PrintEType) const override {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
if (PrintEType)
|
|
|
|
OS << "ExpressionTypeBasic, ";
|
|
|
|
|
|
|
|
this->Expression::printInternal(OS, false);
|
|
|
|
OS << "operands = {";
|
|
|
|
for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
|
|
|
|
OS << "[" << i << "] = ";
|
|
|
|
Operands[i]->printAsOperand(OS);
|
|
|
|
OS << " ";
|
|
|
|
}
|
|
|
|
OS << "} ";
|
|
|
|
}
|
|
|
|
};
|
2017-01-18 01:57:48 +01:00
|
|
|
|
2016-12-26 20:57:25 +01:00
|
|
|
class op_inserter
|
|
|
|
: public std::iterator<std::output_iterator_tag, void, void, void, void> {
|
|
|
|
private:
|
2017-09-13 23:43:53 +02:00
|
|
|
using Container = BasicExpression;
|
|
|
|
|
2016-12-26 20:57:25 +01:00
|
|
|
Container *BE;
|
2016-12-26 21:06:58 +01:00
|
|
|
|
2016-12-26 20:57:25 +01:00
|
|
|
public:
|
|
|
|
explicit op_inserter(BasicExpression &E) : BE(&E) {}
|
|
|
|
explicit op_inserter(BasicExpression *E) : BE(E) {}
|
|
|
|
|
|
|
|
op_inserter &operator=(Value *val) {
|
|
|
|
BE->op_push_back(val);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
op_inserter &operator*() { return *this; }
|
|
|
|
op_inserter &operator++() { return *this; }
|
|
|
|
op_inserter &operator++(int) { return *this; }
|
|
|
|
};
|
|
|
|
|
2017-04-01 11:44:29 +02:00
|
|
|
class MemoryExpression : public BasicExpression {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
private:
|
2017-04-01 11:44:29 +02:00
|
|
|
const MemoryAccess *MemoryLeader;
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
|
|
|
public:
|
2017-04-01 11:44:29 +02:00
|
|
|
MemoryExpression(unsigned NumOperands, enum ExpressionType EType,
|
|
|
|
const MemoryAccess *MemoryLeader)
|
2017-09-13 23:43:53 +02:00
|
|
|
: BasicExpression(NumOperands, EType), MemoryLeader(MemoryLeader) {}
|
2017-04-01 11:44:29 +02:00
|
|
|
MemoryExpression() = delete;
|
|
|
|
MemoryExpression(const MemoryExpression &) = delete;
|
|
|
|
MemoryExpression &operator=(const MemoryExpression &) = delete;
|
2017-09-13 23:43:53 +02:00
|
|
|
|
2017-01-18 01:57:48 +01:00
|
|
|
static bool classof(const Expression *EB) {
|
2017-04-01 11:44:29 +02:00
|
|
|
return EB->getExpressionType() > ET_MemoryStart &&
|
|
|
|
EB->getExpressionType() < ET_MemoryEnd;
|
|
|
|
}
|
2017-09-13 23:43:53 +02:00
|
|
|
|
2017-04-01 11:44:29 +02:00
|
|
|
hash_code getHashValue() const override {
|
|
|
|
return hash_combine(this->BasicExpression::getHashValue(), MemoryLeader);
|
2017-01-18 01:57:48 +01:00
|
|
|
}
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
2017-01-18 01:57:48 +01:00
|
|
|
bool equals(const Expression &Other) const override {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
if (!this->BasicExpression::equals(Other))
|
|
|
|
return false;
|
2017-04-01 11:44:29 +02:00
|
|
|
const MemoryExpression &OtherMCE = cast<MemoryExpression>(Other);
|
|
|
|
|
|
|
|
return MemoryLeader == OtherMCE.MemoryLeader;
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
}
|
|
|
|
|
2017-04-01 11:44:29 +02:00
|
|
|
const MemoryAccess *getMemoryLeader() const { return MemoryLeader; }
|
|
|
|
void setMemoryLeader(const MemoryAccess *ML) { MemoryLeader = ML; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class CallExpression final : public MemoryExpression {
|
|
|
|
private:
|
|
|
|
CallInst *Call;
|
|
|
|
|
|
|
|
public:
|
|
|
|
CallExpression(unsigned NumOperands, CallInst *C,
|
|
|
|
const MemoryAccess *MemoryLeader)
|
|
|
|
: MemoryExpression(NumOperands, ET_Call, MemoryLeader), Call(C) {}
|
|
|
|
CallExpression() = delete;
|
|
|
|
CallExpression(const CallExpression &) = delete;
|
|
|
|
CallExpression &operator=(const CallExpression &) = delete;
|
|
|
|
~CallExpression() override;
|
|
|
|
|
|
|
|
static bool classof(const Expression *EB) {
|
|
|
|
return EB->getExpressionType() == ET_Call;
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Debugging support
|
2017-01-18 01:57:48 +01:00
|
|
|
void printInternal(raw_ostream &OS, bool PrintEType) const override {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
if (PrintEType)
|
|
|
|
OS << "ExpressionTypeCall, ";
|
|
|
|
this->BasicExpression::printInternal(OS, false);
|
2017-04-01 11:44:29 +02:00
|
|
|
OS << " represents call at ";
|
|
|
|
Call->printAsOperand(OS);
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-04-01 11:44:29 +02:00
|
|
|
class LoadExpression final : public MemoryExpression {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
private:
|
|
|
|
LoadInst *Load;
|
|
|
|
|
|
|
|
public:
|
2017-04-01 11:44:29 +02:00
|
|
|
LoadExpression(unsigned NumOperands, LoadInst *L,
|
|
|
|
const MemoryAccess *MemoryLeader)
|
|
|
|
: LoadExpression(ET_Load, NumOperands, L, MemoryLeader) {}
|
2017-09-13 23:43:53 +02:00
|
|
|
|
2016-12-26 21:06:58 +01:00
|
|
|
LoadExpression(enum ExpressionType EType, unsigned NumOperands, LoadInst *L,
|
2017-04-01 11:44:29 +02:00
|
|
|
const MemoryAccess *MemoryLeader)
|
2020-06-06 11:49:20 +02:00
|
|
|
: MemoryExpression(NumOperands, EType, MemoryLeader), Load(L) {}
|
2017-09-13 23:43:53 +02:00
|
|
|
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
LoadExpression() = delete;
|
2017-01-18 01:57:48 +01:00
|
|
|
LoadExpression(const LoadExpression &) = delete;
|
|
|
|
LoadExpression &operator=(const LoadExpression &) = delete;
|
|
|
|
~LoadExpression() override;
|
|
|
|
|
|
|
|
static bool classof(const Expression *EB) {
|
|
|
|
return EB->getExpressionType() == ET_Load;
|
|
|
|
}
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
|
|
|
LoadInst *getLoadInst() const { return Load; }
|
|
|
|
void setLoadInst(LoadInst *L) { Load = L; }
|
|
|
|
|
2017-01-18 01:57:48 +01:00
|
|
|
bool equals(const Expression &Other) const override;
|
2017-06-06 19:15:28 +02:00
|
|
|
bool exactlyEquals(const Expression &Other) const override {
|
|
|
|
return Expression::exactlyEquals(Other) &&
|
|
|
|
cast<LoadExpression>(Other).getLoadInst() == getLoadInst();
|
|
|
|
}
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
|
|
|
// Debugging support
|
2017-01-18 01:57:48 +01:00
|
|
|
void printInternal(raw_ostream &OS, bool PrintEType) const override {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
if (PrintEType)
|
|
|
|
OS << "ExpressionTypeLoad, ";
|
|
|
|
this->BasicExpression::printInternal(OS, false);
|
2017-04-01 11:44:29 +02:00
|
|
|
OS << " represents Load at ";
|
|
|
|
Load->printAsOperand(OS);
|
|
|
|
OS << " with MemoryLeader " << *getMemoryLeader();
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-04-01 11:44:29 +02:00
|
|
|
class StoreExpression final : public MemoryExpression {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
private:
|
|
|
|
StoreInst *Store;
|
NewGVN: Fix PR 31686 and PR 31698 by rewriting store leader handling.
Summary:
This rewrites store expression/leader handling. We no longer use the
value operand as the leader, instead, we store it separately. We also
now store the stored value as part of the expression, and compare it
when comparing stores for equality. This enables us to get rid of a
bunch of our previous hacks and machinations, as the existing
machinery takes care of everything *except* updating the stored value
on classes. The only time we have to update it is if the storecount
goes to 0, and when we do, we destroy it.
Since we no longer use the value operand as the leader, during elimination, we have to use the value operand. Doing this also fixes a bunch of store forwarding cases we were missing.
Any value operand we use is guaranteed to either be updated by previous eliminations, or minimized by future ones.
(IE the fact that we don't use the most dominating value operand when it's not a constant does not affect anything).
Sadly, this change also exposes that we didn't pay attention to the
output of the pr31594.ll test, as it also very clearly exposes the
same store leader bug we are fixing here.
(I added pr31682.ll anyway, but maybe we think that's too large to be useful)
On the plus side, propagate-ir-flags.ll now passes due to the
corrected store forwarding.
This change was 3 stage'd on darwin and linux, with the full test-suite.
Reviewers:
davide
Subscribers:
llvm-commits
llvm-svn: 292648
2017-01-20 22:04:30 +01:00
|
|
|
Value *StoredValue;
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
|
|
|
public:
|
NewGVN: Fix PR 31686 and PR 31698 by rewriting store leader handling.
Summary:
This rewrites store expression/leader handling. We no longer use the
value operand as the leader, instead, we store it separately. We also
now store the stored value as part of the expression, and compare it
when comparing stores for equality. This enables us to get rid of a
bunch of our previous hacks and machinations, as the existing
machinery takes care of everything *except* updating the stored value
on classes. The only time we have to update it is if the storecount
goes to 0, and when we do, we destroy it.
Since we no longer use the value operand as the leader, during elimination, we have to use the value operand. Doing this also fixes a bunch of store forwarding cases we were missing.
Any value operand we use is guaranteed to either be updated by previous eliminations, or minimized by future ones.
(IE the fact that we don't use the most dominating value operand when it's not a constant does not affect anything).
Sadly, this change also exposes that we didn't pay attention to the
output of the pr31594.ll test, as it also very clearly exposes the
same store leader bug we are fixing here.
(I added pr31682.ll anyway, but maybe we think that's too large to be useful)
On the plus side, propagate-ir-flags.ll now passes due to the
corrected store forwarding.
This change was 3 stage'd on darwin and linux, with the full test-suite.
Reviewers:
davide
Subscribers:
llvm-commits
llvm-svn: 292648
2017-01-20 22:04:30 +01:00
|
|
|
StoreExpression(unsigned NumOperands, StoreInst *S, Value *StoredValue,
|
2017-04-01 11:44:29 +02:00
|
|
|
const MemoryAccess *MemoryLeader)
|
|
|
|
: MemoryExpression(NumOperands, ET_Store, MemoryLeader), Store(S),
|
|
|
|
StoredValue(StoredValue) {}
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
StoreExpression() = delete;
|
2017-01-18 01:57:48 +01:00
|
|
|
StoreExpression(const StoreExpression &) = delete;
|
|
|
|
StoreExpression &operator=(const StoreExpression &) = delete;
|
|
|
|
~StoreExpression() override;
|
|
|
|
|
|
|
|
static bool classof(const Expression *EB) {
|
|
|
|
return EB->getExpressionType() == ET_Store;
|
|
|
|
}
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
|
|
|
StoreInst *getStoreInst() const { return Store; }
|
NewGVN: Fix PR 31686 and PR 31698 by rewriting store leader handling.
Summary:
This rewrites store expression/leader handling. We no longer use the
value operand as the leader, instead, we store it separately. We also
now store the stored value as part of the expression, and compare it
when comparing stores for equality. This enables us to get rid of a
bunch of our previous hacks and machinations, as the existing
machinery takes care of everything *except* updating the stored value
on classes. The only time we have to update it is if the storecount
goes to 0, and when we do, we destroy it.
Since we no longer use the value operand as the leader, during elimination, we have to use the value operand. Doing this also fixes a bunch of store forwarding cases we were missing.
Any value operand we use is guaranteed to either be updated by previous eliminations, or minimized by future ones.
(IE the fact that we don't use the most dominating value operand when it's not a constant does not affect anything).
Sadly, this change also exposes that we didn't pay attention to the
output of the pr31594.ll test, as it also very clearly exposes the
same store leader bug we are fixing here.
(I added pr31682.ll anyway, but maybe we think that's too large to be useful)
On the plus side, propagate-ir-flags.ll now passes due to the
corrected store forwarding.
This change was 3 stage'd on darwin and linux, with the full test-suite.
Reviewers:
davide
Subscribers:
llvm-commits
llvm-svn: 292648
2017-01-20 22:04:30 +01:00
|
|
|
Value *getStoredValue() const { return StoredValue; }
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
2017-01-18 01:57:48 +01:00
|
|
|
bool equals(const Expression &Other) const override;
|
2017-09-13 23:43:53 +02:00
|
|
|
|
2017-06-06 19:15:28 +02:00
|
|
|
bool exactlyEquals(const Expression &Other) const override {
|
|
|
|
return Expression::exactlyEquals(Other) &&
|
|
|
|
cast<StoreExpression>(Other).getStoreInst() == getStoreInst();
|
|
|
|
}
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
|
|
|
// Debugging support
|
2017-01-18 01:57:48 +01:00
|
|
|
void printInternal(raw_ostream &OS, bool PrintEType) const override {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
if (PrintEType)
|
|
|
|
OS << "ExpressionTypeStore, ";
|
|
|
|
this->BasicExpression::printInternal(OS, false);
|
2017-04-01 11:44:29 +02:00
|
|
|
OS << " represents Store " << *Store;
|
2017-05-19 22:22:14 +02:00
|
|
|
OS << " with StoredValue ";
|
|
|
|
StoredValue->printAsOperand(OS);
|
|
|
|
OS << " and MemoryLeader " << *getMemoryLeader();
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class AggregateValueExpression final : public BasicExpression {
|
|
|
|
private:
|
|
|
|
unsigned MaxIntOperands;
|
2017-09-13 23:43:53 +02:00
|
|
|
unsigned NumIntOperands = 0;
|
|
|
|
unsigned *IntOperands = nullptr;
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
|
|
|
public:
|
2016-12-26 21:06:58 +01:00
|
|
|
AggregateValueExpression(unsigned NumOperands, unsigned NumIntOperands)
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
: BasicExpression(NumOperands, ET_AggregateValue),
|
2017-09-13 23:43:53 +02:00
|
|
|
MaxIntOperands(NumIntOperands) {}
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
AggregateValueExpression() = delete;
|
2017-01-18 01:57:48 +01:00
|
|
|
AggregateValueExpression(const AggregateValueExpression &) = delete;
|
|
|
|
AggregateValueExpression &
|
|
|
|
operator=(const AggregateValueExpression &) = delete;
|
|
|
|
~AggregateValueExpression() override;
|
|
|
|
|
|
|
|
static bool classof(const Expression *EB) {
|
|
|
|
return EB->getExpressionType() == ET_AggregateValue;
|
|
|
|
}
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
2017-09-13 23:43:53 +02:00
|
|
|
using int_arg_iterator = unsigned *;
|
|
|
|
using const_int_arg_iterator = const unsigned *;
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
2016-12-25 23:10:37 +01:00
|
|
|
int_arg_iterator int_op_begin() { return IntOperands; }
|
|
|
|
int_arg_iterator int_op_end() { return IntOperands + NumIntOperands; }
|
|
|
|
const_int_arg_iterator int_op_begin() const { return IntOperands; }
|
|
|
|
const_int_arg_iterator int_op_end() const {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
return IntOperands + NumIntOperands;
|
|
|
|
}
|
2016-12-25 23:10:37 +01:00
|
|
|
unsigned int_op_size() const { return NumIntOperands; }
|
|
|
|
bool int_op_empty() const { return NumIntOperands == 0; }
|
|
|
|
void int_op_push_back(unsigned IntOperand) {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
assert(NumIntOperands < MaxIntOperands &&
|
|
|
|
"Tried to add too many int operands");
|
|
|
|
assert(IntOperands && "Operands not allocated before pushing");
|
|
|
|
IntOperands[NumIntOperands++] = IntOperand;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void allocateIntOperands(BumpPtrAllocator &Allocator) {
|
|
|
|
assert(!IntOperands && "Operands already allocated");
|
|
|
|
IntOperands = Allocator.Allocate<unsigned>(MaxIntOperands);
|
|
|
|
}
|
|
|
|
|
2017-01-18 01:57:48 +01:00
|
|
|
bool equals(const Expression &Other) const override {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
if (!this->BasicExpression::equals(Other))
|
|
|
|
return false;
|
|
|
|
const AggregateValueExpression &OE = cast<AggregateValueExpression>(Other);
|
2016-12-24 18:14:19 +01:00
|
|
|
return NumIntOperands == OE.NumIntOperands &&
|
2016-12-26 21:06:58 +01:00
|
|
|
std::equal(int_op_begin(), int_op_end(), OE.int_op_begin());
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
}
|
|
|
|
|
2017-01-18 01:57:48 +01:00
|
|
|
hash_code getHashValue() const override {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
return hash_combine(this->BasicExpression::getHashValue(),
|
2016-12-25 23:10:37 +01:00
|
|
|
hash_combine_range(int_op_begin(), int_op_end()));
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Debugging support
|
2017-01-18 01:57:48 +01:00
|
|
|
void printInternal(raw_ostream &OS, bool PrintEType) const override {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
if (PrintEType)
|
|
|
|
OS << "ExpressionTypeAggregateValue, ";
|
|
|
|
this->BasicExpression::printInternal(OS, false);
|
|
|
|
OS << ", intoperands = {";
|
2016-12-25 23:10:37 +01:00
|
|
|
for (unsigned i = 0, e = int_op_size(); i != e; ++i) {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
OS << "[" << i << "] = " << IntOperands[i] << " ";
|
|
|
|
}
|
|
|
|
OS << "}";
|
|
|
|
}
|
|
|
|
};
|
2017-01-18 01:57:48 +01:00
|
|
|
|
2016-12-26 20:57:25 +01:00
|
|
|
class int_op_inserter
|
|
|
|
: public std::iterator<std::output_iterator_tag, void, void, void, void> {
|
|
|
|
private:
|
2017-09-13 23:43:53 +02:00
|
|
|
using Container = AggregateValueExpression;
|
|
|
|
|
2016-12-26 20:57:25 +01:00
|
|
|
Container *AVE;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit int_op_inserter(AggregateValueExpression &E) : AVE(&E) {}
|
|
|
|
explicit int_op_inserter(AggregateValueExpression *E) : AVE(E) {}
|
2017-01-18 01:57:48 +01:00
|
|
|
|
2016-12-26 20:57:25 +01:00
|
|
|
int_op_inserter &operator=(unsigned int val) {
|
|
|
|
AVE->int_op_push_back(val);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
int_op_inserter &operator*() { return *this; }
|
|
|
|
int_op_inserter &operator++() { return *this; }
|
|
|
|
int_op_inserter &operator++(int) { return *this; }
|
|
|
|
};
|
|
|
|
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
class PHIExpression final : public BasicExpression {
|
|
|
|
private:
|
|
|
|
BasicBlock *BB;
|
|
|
|
|
|
|
|
public:
|
|
|
|
PHIExpression(unsigned NumOperands, BasicBlock *B)
|
|
|
|
: BasicExpression(NumOperands, ET_Phi), BB(B) {}
|
|
|
|
PHIExpression() = delete;
|
2017-01-18 01:57:48 +01:00
|
|
|
PHIExpression(const PHIExpression &) = delete;
|
|
|
|
PHIExpression &operator=(const PHIExpression &) = delete;
|
|
|
|
~PHIExpression() override;
|
|
|
|
|
|
|
|
static bool classof(const Expression *EB) {
|
|
|
|
return EB->getExpressionType() == ET_Phi;
|
|
|
|
}
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
2017-01-18 01:57:48 +01:00
|
|
|
bool equals(const Expression &Other) const override {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
if (!this->BasicExpression::equals(Other))
|
|
|
|
return false;
|
|
|
|
const PHIExpression &OE = cast<PHIExpression>(Other);
|
2016-12-24 18:14:19 +01:00
|
|
|
return BB == OE.BB;
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
}
|
|
|
|
|
2017-01-18 01:57:48 +01:00
|
|
|
hash_code getHashValue() const override {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
return hash_combine(this->BasicExpression::getHashValue(), BB);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Debugging support
|
2017-01-18 01:57:48 +01:00
|
|
|
void printInternal(raw_ostream &OS, bool PrintEType) const override {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
if (PrintEType)
|
|
|
|
OS << "ExpressionTypePhi, ";
|
|
|
|
this->BasicExpression::printInternal(OS, false);
|
|
|
|
OS << "bb = " << BB;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-19 22:22:20 +02:00
|
|
|
class DeadExpression final : public Expression {
|
|
|
|
public:
|
|
|
|
DeadExpression() : Expression(ET_Dead) {}
|
|
|
|
DeadExpression(const DeadExpression &) = delete;
|
|
|
|
DeadExpression &operator=(const DeadExpression &) = delete;
|
|
|
|
|
|
|
|
static bool classof(const Expression *E) {
|
|
|
|
return E->getExpressionType() == ET_Dead;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
class VariableExpression final : public Expression {
|
|
|
|
private:
|
|
|
|
Value *VariableValue;
|
|
|
|
|
|
|
|
public:
|
2017-01-18 01:57:48 +01:00
|
|
|
VariableExpression(Value *V) : Expression(ET_Variable), VariableValue(V) {}
|
|
|
|
VariableExpression() = delete;
|
|
|
|
VariableExpression(const VariableExpression &) = delete;
|
|
|
|
VariableExpression &operator=(const VariableExpression &) = delete;
|
|
|
|
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
static bool classof(const Expression *EB) {
|
|
|
|
return EB->getExpressionType() == ET_Variable;
|
|
|
|
}
|
|
|
|
|
|
|
|
Value *getVariableValue() const { return VariableValue; }
|
|
|
|
void setVariableValue(Value *V) { VariableValue = V; }
|
2017-01-18 01:57:48 +01:00
|
|
|
|
|
|
|
bool equals(const Expression &Other) const override {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
const VariableExpression &OC = cast<VariableExpression>(Other);
|
2016-12-24 18:14:19 +01:00
|
|
|
return VariableValue == OC.VariableValue;
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
}
|
|
|
|
|
2017-01-18 01:57:48 +01:00
|
|
|
hash_code getHashValue() const override {
|
2017-04-01 11:44:29 +02:00
|
|
|
return hash_combine(this->Expression::getHashValue(),
|
|
|
|
VariableValue->getType(), VariableValue);
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Debugging support
|
2017-01-18 01:57:48 +01:00
|
|
|
void printInternal(raw_ostream &OS, bool PrintEType) const override {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
if (PrintEType)
|
|
|
|
OS << "ExpressionTypeVariable, ";
|
|
|
|
this->Expression::printInternal(OS, false);
|
|
|
|
OS << " variable = " << *VariableValue;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class ConstantExpression final : public Expression {
|
|
|
|
private:
|
2017-01-18 01:57:48 +01:00
|
|
|
Constant *ConstantValue = nullptr;
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
|
|
|
public:
|
2017-01-18 01:57:48 +01:00
|
|
|
ConstantExpression() : Expression(ET_Constant) {}
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
ConstantExpression(Constant *constantValue)
|
|
|
|
: Expression(ET_Constant), ConstantValue(constantValue) {}
|
|
|
|
ConstantExpression(const ConstantExpression &) = delete;
|
2017-01-18 01:57:48 +01:00
|
|
|
ConstantExpression &operator=(const ConstantExpression &) = delete;
|
|
|
|
|
|
|
|
static bool classof(const Expression *EB) {
|
|
|
|
return EB->getExpressionType() == ET_Constant;
|
|
|
|
}
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
|
|
|
Constant *getConstantValue() const { return ConstantValue; }
|
|
|
|
void setConstantValue(Constant *V) { ConstantValue = V; }
|
|
|
|
|
2017-01-18 01:57:48 +01:00
|
|
|
bool equals(const Expression &Other) const override {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
const ConstantExpression &OC = cast<ConstantExpression>(Other);
|
|
|
|
return ConstantValue == OC.ConstantValue;
|
|
|
|
}
|
|
|
|
|
2017-01-18 01:57:48 +01:00
|
|
|
hash_code getHashValue() const override {
|
2017-04-01 11:44:29 +02:00
|
|
|
return hash_combine(this->Expression::getHashValue(),
|
|
|
|
ConstantValue->getType(), ConstantValue);
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Debugging support
|
2017-01-18 01:57:48 +01:00
|
|
|
void printInternal(raw_ostream &OS, bool PrintEType) const override {
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
if (PrintEType)
|
|
|
|
OS << "ExpressionTypeConstant, ";
|
|
|
|
this->Expression::printInternal(OS, false);
|
|
|
|
OS << " constant = " << *ConstantValue;
|
|
|
|
}
|
|
|
|
};
|
2017-01-02 19:00:53 +01:00
|
|
|
|
|
|
|
class UnknownExpression final : public Expression {
|
|
|
|
private:
|
|
|
|
Instruction *Inst;
|
|
|
|
|
|
|
|
public:
|
2017-01-18 01:57:48 +01:00
|
|
|
UnknownExpression(Instruction *I) : Expression(ET_Unknown), Inst(I) {}
|
|
|
|
UnknownExpression() = delete;
|
|
|
|
UnknownExpression(const UnknownExpression &) = delete;
|
|
|
|
UnknownExpression &operator=(const UnknownExpression &) = delete;
|
|
|
|
|
2017-01-02 19:00:53 +01:00
|
|
|
static bool classof(const Expression *EB) {
|
|
|
|
return EB->getExpressionType() == ET_Unknown;
|
|
|
|
}
|
|
|
|
|
|
|
|
Instruction *getInstruction() const { return Inst; }
|
|
|
|
void setInstruction(Instruction *I) { Inst = I; }
|
2017-01-18 01:57:48 +01:00
|
|
|
|
|
|
|
bool equals(const Expression &Other) const override {
|
2017-01-02 19:00:53 +01:00
|
|
|
const auto &OU = cast<UnknownExpression>(Other);
|
|
|
|
return Inst == OU.Inst;
|
|
|
|
}
|
2017-01-18 01:57:48 +01:00
|
|
|
|
|
|
|
hash_code getHashValue() const override {
|
2017-04-01 11:44:29 +02:00
|
|
|
return hash_combine(this->Expression::getHashValue(), Inst);
|
2017-01-02 19:00:53 +01:00
|
|
|
}
|
2017-01-18 01:57:48 +01:00
|
|
|
|
2017-01-02 19:00:53 +01:00
|
|
|
// Debugging support
|
2017-01-18 01:57:48 +01:00
|
|
|
void printInternal(raw_ostream &OS, bool PrintEType) const override {
|
2017-01-02 19:00:53 +01:00
|
|
|
if (PrintEType)
|
|
|
|
OS << "ExpressionTypeUnknown, ";
|
|
|
|
this->Expression::printInternal(OS, false);
|
|
|
|
OS << " inst = " << *Inst;
|
|
|
|
}
|
|
|
|
};
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
|
2017-01-18 01:57:48 +01:00
|
|
|
} // end namespace GVNExpression
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif // LLVM_TRANSFORMS_SCALAR_GVNEXPRESSION_H
|