Commit 6509deb8 authored by Marius Wachtler's avatar Marius Wachtler

Don't emit duplicate attr guards

pyston (calibration)                      :    0.8s stock2: 0.8 (+2.5%)
pyston interp2.py                         :    5.9s stock2: 6.2 (-4.5%)
pyston raytrace.py                        :    6.9s stock2: 7.0 (-1.6%)
pyston nbody.py                           :    9.8s stock2: 9.6 (+1.9%)
pyston fannkuch.py                        :    7.0s stock2: 6.9 (+2.6%)
pyston chaos.py                           :   20.6s stock2: 21.6 (-4.6%)
pyston spectral_norm.py                   :   27.9s stock2: 34.2 (-18.6%)
pyston fasta.py                           :   17.1s stock2: 17.8 (-4.5%)
pyston pidigits.py                        :    4.4s stock2: 4.5 (-1.0%)
pyston richards.py                        :   10.4s stock2: 10.2 (+2.2%)
pyston deltablue.py                       :    2.2s stock2: 2.2 (-1.9%)
pyston (geomean-0b9f)                     :    8.8s stock2: 9.1 (-3.2%)
parent a3a12bb6
...@@ -174,6 +174,8 @@ void Rewriter::_addGuardNotEq(RewriterVar* var, uint64_t val) { ...@@ -174,6 +174,8 @@ void Rewriter::_addGuardNotEq(RewriterVar* var, uint64_t val) {
} }
void RewriterVar::addAttrGuard(int offset, uint64_t val, bool negate) { void RewriterVar::addAttrGuard(int offset, uint64_t val, bool negate) {
if (!attr_guards.insert(std::make_tuple(offset, val, negate)).second)
return; // duplicate guard detected
rewriter->addAction([=]() { rewriter->_addAttrGuard(this, offset, val, negate); }, { this }, ActionType::GUARD); rewriter->addAction([=]() { rewriter->_addAttrGuard(this, offset, val, negate); }, { this }, ActionType::GUARD);
} }
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include <tuple>
#include "llvm/ADT/SmallSet.h"
#include "asm_writing/assembler.h" #include "asm_writing/assembler.h"
#include "asm_writing/icinfo.h" #include "asm_writing/icinfo.h"
...@@ -248,6 +251,8 @@ private: ...@@ -248,6 +251,8 @@ private:
bool is_arg; bool is_arg;
Location arg_loc; Location arg_loc;
llvm::SmallSet<std::tuple<int, uint64_t, bool>, 4> attr_guards; // used to detect duplicate guards
// Gets a copy of this variable in a register, spilling/reloading if necessary. // Gets a copy of this variable in a register, spilling/reloading if necessary.
// TODO have to be careful with the result since the interface doesn't guarantee // TODO have to be careful with the result since the interface doesn't guarantee
// that the register will still contain your value when you go to use it // that the register will still contain your value when you go to use it
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment