MAX_RISCV_ENTITIES
};
+/* RISC-V stringop strategy. */
+enum riscv_stringop_strategy_enum {
+ /* Use scalar or vector instructions. */
+ USE_AUTO,
+ /* Always use a library call. */
+ USE_LIBCALL,
+ /* Only use scalar instructions. */
+ USE_SCALAR,
+ /* Only use vector instructions. */
+ USE_VECTOR
+};
+
#define TARGET_ZICOND_LIKE (TARGET_ZICOND || (TARGET_XVENTANACONDOPS && TARGET_64BIT))
/* Bit of riscv_zvl_flags will set contintuly, N-1 bit will set if N-bit is
bool
riscv_expand_block_move (rtx dest, rtx src, rtx length)
{
+ if (riscv_memcpy_strategy == USE_LIBCALL
+ || riscv_memcpy_strategy == USE_VECTOR)
+ return false;
+
if (CONST_INT_P (length))
{
unsigned HOST_WIDE_INT hwi_length = UINTVAL (length);
bnez a2, loop # Any more?
ret # Return
*/
- if (!TARGET_VECTOR)
+ if (!TARGET_VECTOR || riscv_memcpy_strategy == USE_LIBCALL
+ || riscv_memcpy_strategy == USE_SCALAR)
return false;
HOST_WIDE_INT potential_ew
= (MIN (MIN (MEM_ALIGN (src_in), MEM_ALIGN (dst_in)), BITS_PER_WORD)
Target Undocumented Bool Var(riscv_vector_abi) Init(0)
Enable the use of vector registers for function arguments and return value.
This is an experimental switch and may be subject to change in the future.
+
+Enum
+Name(riscv_stringop_strategy) Type(enum riscv_stringop_strategy_enum)
+Valid arguments to -mmemcpy-strategy=:
+
+EnumValue
+Enum(riscv_stringop_strategy) String(auto) Value(USE_AUTO)
+
+EnumValue
+Enum(riscv_stringop_strategy) String(libcall) Value(USE_LIBCALL)
+
+EnumValue
+Enum(riscv_stringop_strategy) String(scalar) Value(USE_SCALAR)
+
+EnumValue
+Enum(riscv_stringop_strategy) String(vector) Value(USE_VECTOR)
+
+mmemcpy-strategy=
+Target RejectNegative Joined Enum(riscv_stringop_strategy) Var(riscv_memcpy_strategy) Init(USE_AUTO)
+Specify memcpy expansion strategy.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-march=rv32gcv -mabi=ilp32d -mmemcpy-strategy=libcall" } */
+
+#include "cpymem-strategy.h"
+
+/* { dg-final { scan-assembler-times {call\tmemcpy} 2 } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=rv32gcv -mabi=ilp32d -mmemcpy-strategy=scalar" } */
+
+#include "cpymem-strategy.h"
+
+/* { dg-final { scan-assembler-times {call\tmemcpy} 1 } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-march=rv32gcv -mabi=ilp32d -mmemcpy-strategy=vector" } */
+
+#include "cpymem-strategy.h"
+
+/* { dg-final { scan-assembler-times {v[ls]+e[0-9]+\.v\tv[0-9]+\,0\([a-z0-9]+\)} 4 } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-march=rv32gcv -mabi=ilp32d -mmemcpy-strategy=auto" } */
+
+#include "cpymem-strategy.h"
+
+/* { dg-final { scan-assembler-times {v[ls]+e[0-9]+\.v\tv[0-9]+\,0\([a-z0-9]+\)} 4 } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-march=rv32gc -mabi=ilp32d -mmemcpy-strategy=vector" } */
+
+#include "cpymem-strategy.h"
+
+/* { dg-final { scan-assembler-times {call\tmemcpy} 2 } } */
--- /dev/null
+typedef struct { unsigned char a[56]; } a56;
+typedef struct { int b[32]; } b32;
+
+void f1 (a56 *v1, a56 *v2)
+{
+ *v1 = *v2;
+}
+
+void f2 (b32 *v1, b32 *v2)
+{
+ *v1 = *v2;
+}