Some constants can be built up using rotate-right instructions.
The code that enables this can be found in riscv_build_integer_1().
However, this functionality is only available for Zbb, which
includes the rori instruction. This patch enables this also for
XTheadBb, which includes the th.srri instruction.
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_build_integer_1): Enable constant
synthesis with rotate-right for XTheadBb.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/xtheadbb-li-rotr.c: New test.
}
}
- if (cost > 2 && TARGET_64BIT && TARGET_ZBB)
+ if (cost > 2 && TARGET_64BIT && (TARGET_ZBB || TARGET_XTHEADBB))
{
int leading_ones = clz_hwi (~value);
int trailing_ones = ctz_hwi (~value);
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_xtheadbb" } */
+
+long
+li_rori (void)
+{
+ return 0xffff77ffffffffffL;
+}
+
+long
+li_rori_2 (void)
+{
+ return 0x77ffffffffffffffL;
+}
+
+long
+li_rori_3 (void)
+{
+ return 0xfffffffeefffffffL;
+}
+
+long
+li_rori_4 (void)
+{
+ return 0x5ffffffffffffff5L;
+}
+
+long
+li_rori_5 (void)
+{
+ return 0xaffffffffffffffaL;
+}
+
+/* { dg-final { scan-assembler-times "th.srri\t" 5 } } */