execution and fusion in the constant synthesis those would naturally
decrease the budget. It also does not account for the IOR/XOR at
the end of the sequence which would increase the budget. */
- int budget = (TARGET_ZBS ? riscv_const_insns (operands[2], true) : -1);
+ int budget = (TARGET_ZBS ? riscv_integer_cost (INTVAL (operands[2]), true) : -1);
int original_budget = budget;
/* Bits we need to set in operands[0]. As we synthesize the operation,
if ((TARGET_ZBB || TARGET_XTHEADBB || TARGET_ZBKB)
&& budget < 0
&& popcount_hwi (INTVAL (operands[2])) <= 11
- && riscv_const_insns (operands[2], true) >= 3)
+ && riscv_integer_cost (INTVAL (operands[2]), true) >= 3)
{
ival = INTVAL (operands[2]);
/* First see if the constant trivially fits into 11 bits in the LSB. */
we have Zbb, then we have XNOR and ORN. So if the inverted constant
is cheaper, invert it and use XNOR/ORN. */
if (TARGET_ZBB
- && riscv_const_insns (GEN_INT (~UINTVAL (operands[2])), true) > 0
- && (riscv_const_insns (operands[2], true)
- > riscv_const_insns (GEN_INT (~UINTVAL (operands[2])), true)))
+ && (riscv_integer_cost (INTVAL (operands[2]), true)
+ > riscv_integer_cost (~UINTVAL (operands[2]), true)))
{
rtx x = force_reg (word_mode, GEN_INT (~UINTVAL (operands[2])));
--- /dev/null
+/* { dg-do compile { target rv64 } } */
+/* { dg-options "-march=rv64gcb -mabi=lp64d" } */
+
+
+
+#define T(X) long xnor##X(long x) { return x ^ X; }
+
+T(0x000200c3233fffffUL)
+T(0x300000000003ffffUL)
+T(0x00004f10000a0fffUL)
+T(0x0000c7f3801fefffUL)
+T(0xe00000000000fc00UL)
+T(0x0eef7ffffffbbfffUL)
+T(0xff0000000000ff00UL)
+
+/* Each test above is better handled by inverting the constant
+ and using xnor. */
+
+/* { dg-final { scan-assembler-times "\\txnor\\t" 7 } } */