+2017-06-09 Martin Liska <mliska@suse.cz>
+
+ * predict.c (struct branch_predictor): New struct.
+ (test_prediction_value_range): New test.
+ (predict_c_tests): New function.
+ * selftest-run-tests.c (selftest::run_tests): Run the function.
+ * selftest.h: Declare new tests.
+
2017-06-09 Segher Boessenkool <segher@kernel.crashing.org>
PR target/80966
#include "tree-scalar-evolution.h"
#include "ipa-utils.h"
#include "gimple-pretty-print.h"
+#include "selftest.h"
/* Enum with reasons why a predictor is ignored. */
impossible ? "impossible" : "cold");
}
}
+
+#if CHECKING_P
+
+namespace selftest {
+
+/* Test that value range of predictor values defined in predict.def is
+ within range (50, 100]. */
+
+struct branch_predictor
+{
+ const char *name;
+ unsigned probability;
+};
+
+#define DEF_PREDICTOR(ENUM, NAME, HITRATE, FLAGS) { NAME, HITRATE },
+
+static void
+test_prediction_value_range ()
+{
+ branch_predictor predictors[] = {
+#include "predict.def"
+ {NULL, -1}
+ };
+
+ for (unsigned i = 0; predictors[i].name != NULL; i++)
+ {
+ unsigned p = 100 * predictors[i].probability / REG_BR_PROB_BASE;
+ ASSERT_TRUE (p > 50 && p <= 100);
+ }
+}
+
+#undef DEF_PREDICTOR
+
+/* Run all of the selfests within this file. */
+
+void
+predict_c_tests ()
+{
+ test_prediction_value_range ();
+}
+
+} // namespace selftest
+#endif /* CHECKING_P. */
targetm.run_target_selftests ();
store_merging_c_tests ();
+ predict_c_tests ();
/* Run any lang-specific selftests. */
lang_hooks.run_lang_selftests ();
extern void tree_cfg_c_tests ();
extern void vec_c_tests ();
extern void wide_int_cc_tests ();
+extern void predict_c_tests ();
extern int num_passes;