return df_find_use (insn, reg) != NULL;
}
+/* If REG has a single definition, return its known value, otherwise return
+ null. */
+
+rtx
+df_find_single_def_src (rtx reg)
+{
+ rtx src = NULL_RTX;
+
+ /* Don't look through unbounded number of single definition REG copies,
+ there might be loops for sources with uninitialized variables. */
+ for (int cnt = 0; cnt < 128; cnt++)
+ {
+ df_ref adef = DF_REG_DEF_CHAIN (REGNO (reg));
+ if (adef == NULL || DF_REF_NEXT_REG (adef) != NULL
+ || DF_REF_IS_ARTIFICIAL (adef)
+ || (DF_REF_FLAGS (adef)
+ & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
+ return NULL_RTX;
+
+ rtx set = single_set (DF_REF_INSN (adef));
+ if (set == NULL || !rtx_equal_p (SET_DEST (set), reg))
+ return NULL_RTX;
+
+ rtx note = find_reg_equal_equiv_note (DF_REF_INSN (adef));
+ if (note && function_invariant_p (XEXP (note, 0)))
+ return XEXP (note, 0);
+ src = SET_SRC (set);
+
+ if (REG_P (src))
+ {
+ reg = src;
+ continue;
+ }
+ break;
+ }
+ if (!function_invariant_p (src))
+ return NULL_RTX;
+
+ return src;
+}
+
\f
/*----------------------------------------------------------------------------
Debugging and printing functions.
extern bool df_reg_defined (rtx_insn *, rtx);
extern df_ref df_find_use (rtx_insn *, rtx);
extern bool df_reg_used (rtx_insn *, rtx);
+extern rtx df_find_single_def_src (rtx);
extern void df_worklist_dataflow (struct dataflow *,bitmap, int *, int);
extern void df_print_regset (FILE *file, const_bitmap r);
extern void df_print_word_regset (FILE *file, const_bitmap r);
if (tem && CONSTANT_P (tem))
const_rhs = tem;
+ else
+ {
+ /* If RHS is set only once to a constant, set CONST_RHS
+ to the constant. */
+ rtx def_src = df_find_single_def_src (rhs);
+ if (def_src != nullptr && CONSTANT_P (def_src))
+ const_rhs = def_src;
+ }
}
}
}
}
-/* If REGNO has a single definition, return its known value, otherwise return
- null. */
-
-static rtx
-find_single_def_src (unsigned int regno)
-{
- rtx src = NULL_RTX;
-
- /* Don't look through unbounded number of single definition REG copies,
- there might be loops for sources with uninitialized variables. */
- for (int cnt = 0; cnt < 128; cnt++)
- {
- df_ref adef = DF_REG_DEF_CHAIN (regno);
- if (adef == NULL || DF_REF_NEXT_REG (adef) != NULL
- || DF_REF_IS_ARTIFICIAL (adef))
- return NULL_RTX;
-
- rtx set = single_set (DF_REF_INSN (adef));
- if (set == NULL || !REG_P (SET_DEST (set))
- || REGNO (SET_DEST (set)) != regno)
- return NULL_RTX;
-
- rtx note = find_reg_equal_equiv_note (DF_REF_INSN (adef));
- if (note && function_invariant_p (XEXP (note, 0)))
- {
- src = XEXP (note, 0);
- break;
- }
- src = SET_SRC (set);
-
- if (REG_P (src))
- {
- regno = REGNO (src);
- continue;
- }
- break;
- }
- if (!function_invariant_p (src))
- return NULL_RTX;
-
- return src;
-}
-
/* If any registers in *EXPR that have a single definition, try to replace
them with the known-equivalent values. */
{
rtx x = *iter;
if (REG_P (x))
- if (rtx new_x = find_single_def_src (REGNO (x)))
+ if (rtx new_x = df_find_single_def_src (x))
{
*expr = simplify_replace_rtx (*expr, x, new_x);
goto repeat;
--- /dev/null
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-std=gnu++20 -O2 -march=skylake" } */
+/* { dg-final { scan-assembler-not "vpxor" } } */
+
+#include <stdint.h>
+#include <vector>
+#include <tr1/array>
+
+class FastBoard {
+public:
+ typedef std::pair<int, int> movescore_t;
+ typedef std::tr1::array<movescore_t, 24> scoredlist_t;
+
+protected:
+ std::vector<int> m_critical;
+
+ int m_boardsize;
+};
+
+class FastState {
+public:
+ FastBoard board;
+
+ int movenum;
+protected:
+ FastBoard::scoredlist_t scoredmoves;
+};
+
+class KoState : public FastState {
+private:
+ std::vector<uint64_t> ko_hash_history;
+ std::vector<uint64_t> hash_history;
+};
+
+class GameState : public KoState {
+public:
+ void foo ();
+private:
+ std::vector<KoState> game_history;
+};
+
+void GameState::foo() {
+ game_history.resize(movenum);
+}