[llvm-commits] [PATCH 07/20] [AVX] Unique BitInit
David Greene
dag at cray.com
Tue Jul 19 13:11:42 PDT 2011
Keep only two copies of BitInit: one for true and one for false.
---
utils/TableGen/Record.cpp | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git oldutils/TableGen/Record.cpp newutils/TableGen/Record.cpp
index 72b1f5f..68ac572 100644
--- oldutils/TableGen/Record.cpp
+++ newutils/TableGen/Record.cpp
@@ -405,7 +405,15 @@ const UnsetInit *UnsetInit::get() {
}
const BitInit *BitInit::get(bool V) {
- return new BitInit(V);
+ static const BitInit *True = 0;
+ static const BitInit *False = 0;
+
+ const BitInit **Result = (V ? &True : &False);
+
+ if (*Result == 0)
+ *Result = new BitInit(V);
+
+ return *Result;
}
const BitsInit *BitsInit::get(ArrayRef<const Init *> Range) {
--
1.7.6
More information about the llvm-commits
mailing list