Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: crosstest/test_strengthreduce_main.cpp

Issue 1146803002: Subzero: Strength-reduce mul by certain constants. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Remove a TODO Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « crosstest/test_strengthreduce.def ('k') | pydir/crosstest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crosstest/test_strengthreduce_main.cpp
diff --git a/crosstest/test_strengthreduce_main.cpp b/crosstest/test_strengthreduce_main.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2c2aa986ca40b1353316a57c2f2c7024eea4178a
--- /dev/null
+++ b/crosstest/test_strengthreduce_main.cpp
@@ -0,0 +1,65 @@
+//===- subzero/crosstest/test_strengthreduce_main.cpp - Driver for tests --===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Driver for crosstesting arithmetic strength-reducing optimizations.
+//
+//===----------------------------------------------------------------------===//
+
+/* crosstest.py --test=test_strengthreduce.cpp \
+ --driver=test_strengthreduce_main.cpp \
+ --prefix=Subzero_ --clang-opt=0 --output=test_strengthreduce */
+
+#include <iostream>
+
+// Include test_strengthreduce.h twice - once normally, and once
+// within the Subzero_ namespace, corresponding to the llc and Subzero
+// translated object files, respectively.
+#include "test_strengthreduce.h"
+namespace Subzero_ {
+#include "test_strengthreduce.h"
+}
+
+int main(int argc, char **argv) {
+ size_t TotalTests = 0;
+ size_t Passes = 0;
+ size_t Failures = 0;
+ static int32_t Values[] = {-100, -50, 0, 1, 8, 123, 0x33333333, 0x77777777};
+ for (size_t i = 0; i < sizeof(Values) / sizeof(*Values); ++i) {
+ int32_t SVal = Values[i];
+ int32_t ResultLlcS, ResultSzS;
+ uint32_t UVal = (uint32_t)Values[i];
+ int32_t ResultLlcU, ResultSzU;
+
+#define X(constant, suffix) \
+ ResultLlcS = multiplyByConst##suffix(UVal); \
+ ResultSzS = Subzero_::multiplyByConst##suffix(UVal); \
+ if (ResultLlcS == ResultSzS) { \
+ ++Passes; \
+ } else { \
+ ++Failures; \
+ std::cout << "multiplyByConstS" STR(suffix) "(" << SVal \
+ << "): sz=" << ResultSzS << " llc=" << ResultLlcS << "\n"; \
+ } \
+ ResultLlcU = multiplyByConst##suffix(UVal); \
+ ResultSzU = Subzero_::multiplyByConst##suffix(UVal); \
+ if (ResultLlcU == ResultSzU) { \
+ ++Passes; \
+ } else { \
+ ++Failures; \
+ std::cout << "multiplyByConstU" STR(suffix) "(" << UVal \
+ << "): sz=" << ResultSzU << " llc=" << ResultLlcU << "\n"; \
+ }
+ CONST_TABLE
+#undef X
+ }
+
+ std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes
+ << " Failures=" << Failures << "\n";
+ return Failures;
+}
« no previous file with comments | « crosstest/test_strengthreduce.def ('k') | pydir/crosstest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698