Commit ad421159 by Bin Cheng Committed by Bin Cheng

re PR target/55701 (Inline some instances of memset for ARM)


	PR target/55701
	* config/arm/arm.md (setmem): New pattern.
	* config/arm/arm-protos.h (struct tune_params): New fields.
	(arm_gen_setmem): New prototype.
	* config/arm/arm.c (arm_slowmul_tune): Initialize new fields.
	(arm_fastmul_tune, arm_strongarm_tune, arm_xscale_tune): Ditto.
	(arm_9e_tune, arm_v6t2_tune, arm_cortex_tune): Ditto.
	(arm_cortex_a8_tune, arm_cortex_a7_tune): Ditto.
	(arm_cortex_a15_tune, arm_cortex_a53_tune): Ditto.
	(arm_cortex_a57_tune, arm_cortex_a5_tune): Ditto.
	(arm_cortex_a9_tune, arm_cortex_a12_tune): Ditto.
	(arm_v7m_tune, arm_v6m_tune, arm_fa726te_tune): Ditto.
	(arm_const_inline_cost): New function.
	(arm_block_set_max_insns): New function.
	(arm_block_set_non_vect_profit_p): New function.
	(arm_block_set_vect_profit_p): New function.
	(arm_block_set_unaligned_vect): New function.
	(arm_block_set_aligned_vect): New function.
	(arm_block_set_unaligned_non_vect): New function.
	(arm_block_set_aligned_non_vect): New function.
	(arm_block_set_vect, arm_gen_setmem): New functions.

	testsuite
	* gcc.target/arm/memset-inline-1.c: New test.
	* gcc.target/arm/memset-inline-2.c: New test.
	* gcc.target/arm/memset-inline-3.c: New test.
	* gcc.target/arm/memset-inline-4.c: New test.
	* gcc.target/arm/memset-inline-5.c: New test.
	* gcc.target/arm/memset-inline-6.c: New test.
	* gcc.target/arm/memset-inline-7.c: New test.
	* gcc.target/arm/memset-inline-8.c: New test.
	* gcc.target/arm/memset-inline-9.c: New test.
	* gcc.target/arm/memset-inline-10.c: New test.

From-SVN: r214937
parent 6f221224
2014-09-05 Bin Cheng <bin.cheng@arm.com>
PR target/55701
* config/arm/arm.md (setmem): New pattern.
* config/arm/arm-protos.h (struct tune_params): New fields.
(arm_gen_setmem): New prototype.
* config/arm/arm.c (arm_slowmul_tune): Initialize new fields.
(arm_fastmul_tune, arm_strongarm_tune, arm_xscale_tune): Ditto.
(arm_9e_tune, arm_v6t2_tune, arm_cortex_tune): Ditto.
(arm_cortex_a8_tune, arm_cortex_a7_tune): Ditto.
(arm_cortex_a15_tune, arm_cortex_a53_tune): Ditto.
(arm_cortex_a57_tune, arm_cortex_a5_tune): Ditto.
(arm_cortex_a9_tune, arm_cortex_a12_tune): Ditto.
(arm_v7m_tune, arm_v6m_tune, arm_fa726te_tune): Ditto.
(arm_const_inline_cost): New function.
(arm_block_set_max_insns): New function.
(arm_block_set_non_vect_profit_p): New function.
(arm_block_set_vect_profit_p): New function.
(arm_block_set_unaligned_vect): New function.
(arm_block_set_aligned_vect): New function.
(arm_block_set_unaligned_non_vect): New function.
(arm_block_set_aligned_non_vect): New function.
(arm_block_set_vect, arm_gen_setmem): New functions.
2014-09-05 Bin Cheng <bin.cheng@arm.com>
* config/arm/arm.md (arm_movqi_insn): Use Uh instead of m constraint.
2014-09-05 Bin Cheng <bin.cheng@arm.com>
......@@ -278,6 +278,10 @@ struct tune_params
/* Prefer 32-bit encoding instead of 16-bit encoding where subset of flags
would be set. */
bool disparage_partial_flag_setting_t16_encodings;
/* Prefer to inline string operations like memset by using Neon. */
bool string_ops_prefer_neon;
/* Maximum number of instructions to inline calls to memset. */
int max_insns_inline_memset;
};
extern const struct tune_params *current_tune;
......@@ -290,6 +294,7 @@ extern void arm_emit_coreregs_64bit_shift (enum rtx_code, rtx, rtx, rtx, rtx,
extern bool arm_validize_comparison (rtx *, rtx *, rtx *);
#endif /* RTX_CODE */
extern bool arm_gen_setmem (rtx *);
extern void arm_expand_vec_perm (rtx target, rtx op0, rtx op1, rtx sel);
extern bool arm_expand_vec_perm_const (rtx target, rtx op0, rtx op1, rtx sel);
......
......@@ -6716,6 +6716,20 @@
})
(define_expand "setmemsi"
[(match_operand:BLK 0 "general_operand" "")
(match_operand:SI 1 "const_int_operand" "")
(match_operand:SI 2 "const_int_operand" "")
(match_operand:SI 3 "const_int_operand" "")]
"TARGET_32BIT"
{
if (arm_gen_setmem (operands))
DONE;
FAIL;
})
;; Move a block of memory if it is word aligned and MORE than 2 words long.
;; We could let this apply for blocks of less than this, but it clobbers so
;; many registers that there is then probably a better way.
......
2014-09-05 Bin Cheng <bin.cheng@arm.com>
PR target/55701
* gcc.target/arm/memset-inline-1.c: New test.
* gcc.target/arm/memset-inline-2.c: New test.
* gcc.target/arm/memset-inline-3.c: New test.
* gcc.target/arm/memset-inline-4.c: New test.
* gcc.target/arm/memset-inline-5.c: New test.
* gcc.target/arm/memset-inline-6.c: New test.
* gcc.target/arm/memset-inline-7.c: New test.
* gcc.target/arm/memset-inline-8.c: New test.
* gcc.target/arm/memset-inline-9.c: New test.
* gcc.target/arm/memset-inline-10.c: New test.
2014-09-04 Kaz Kojima <kkojima@gcc.gnu.org>
* gcc.c-torture/execute/pr44683.c: Remove dg-options for sh*-*-*.
......
/* { dg-do run } */
/* { dg-options "-save-temps -O2 -fno-inline" } */
#include <string.h>
#include <stdlib.h>
#define LEN (100)
short a[LEN];
void
foo (void)
{
memset (a, -1, 14);
return;
}
void
check (signed char *arr, int idx, int len, int v)
{
int i;
for (i = 0; i < idx; i++)
if (arr[i] != v)
abort ();
for (i = idx; i < len; i++)
if (arr[i] != 0)
abort ();
}
int
main(void)
{
foo ();
check ((signed char *)a, 14, sizeof (a), -1);
return 0;
}
/* { dg-final { scan-assembler-not "bl?\[ \t\]*memset" { target { arm_thumb2_ok } } } } */
/* { dg-final { cleanup-saved-temps } } */
/* { dg-do compile } */
/* { dg-options "-march=armv7-a -mfloat-abi=hard -mfpu=neon -O2" } */
#define BUF 100
long a[BUF];
typedef unsigned int size_t;
typedef unsigned int wchar_t;
void *memset (void *s, int c, size_t n);
struct printf_info
{
int prec;
int width;
wchar_t spec;
unsigned int is_long_double:1;
unsigned int is_short:1;
unsigned int is_long:1;
unsigned int alt:1;
unsigned int space:1;
unsigned int left:1;
unsigned int showsign:1;
unsigned int group:1;
unsigned int extra:1;
unsigned int is_char:1;
unsigned int wide:1;
unsigned int i18n:1;
unsigned int __pad:4;
unsigned short int user;
wchar_t pad;
};
void bar (int *alt, int *space, int *left, int *showsign,
int *group,
int *is_long_double,
int *is_short,
int *is_long,
int *width,
int *prec,
int *use_outdigits,
unsigned int *pad,
wchar_t *spec);
void __printf_fp (char *s, struct printf_info *pinfo);
int foo(char *s)
{
int alt = 0;
int space = 0;
int left = 0;
int showsign = 0;
int group = 0;
int is_long_double = 0;
int is_short = 0;
int is_long = 0;
int width = 0;
int prec = -1;
int use_outdigits = 0;
unsigned int pad = L' ';
wchar_t spec;
bar (&alt, &space, &left, &showsign, &group, &is_long_double,
&is_short, &is_long, &width, &prec, &use_outdigits, &pad, &spec);
a[1] = a[0] + a[2] + a[3] + a[4] + a[5] + a[6];
a[2] = a[1] + a[3] + a[5] + a[5] + a[6] + a[7];
a[3] = a[2] + a[5] + a[7] + a[6] + a[7] + a[8];
a[4] = a[3] + a[7] + a[11] + a[7] + a[8] + a[9];
a[5] = a[5] + a[11] + a[13] + a[8] + a[9] + a[10];
a[6] = a[7] + a[13] + a[17] + a[9] + a[10] + a[11];
a[7] = a[11] + a[17] + a[19] + a[10] + a[11] + a[12];
a[8] = a[17] + a[19] + a[23] + a[29] + a[31] + a[37];
{
struct printf_info info;
memset (&info, 0, sizeof (struct printf_info));
info.prec = prec;
info.width = width;
info.spec = spec;
info.is_long_double = is_long_double;
info.is_short = is_short;
info.is_long = is_long;
info.alt = alt;
info.space = space;
info.left = left;
info.showsign = showsign;
info.group = group;
info.pad = pad;
info.extra = 0;
info.i18n = use_outdigits;
info.wide = sizeof (wchar_t) != 1;
__printf_fp (s, &info);
}
return 0;
}
/* { dg-do run } */
/* { dg-options "-save-temps -Os -fno-inline" } */
#include <string.h>
#include <stdlib.h>
#define LEN (100)
short a[LEN];
void
foo (void)
{
memset (a, -1, 14);
return;
}
void
check (signed char *arr, int idx, int len, int v)
{
int i;
for (i = 0; i < idx; i++)
if (arr[i] != v)
abort ();
for (i = idx; i < len; i++)
if (arr[i] != 0)
abort ();
}
int
main(void)
{
foo ();
check ((signed char *)a, 14, sizeof (a), -1);
return 0;
}
/* { dg-final { scan-assembler "bl?\[ \t\]*memset" { target { ! arm_neon } } } } */
/* { dg-final { cleanup-saved-temps } } */
/* { dg-do run } */
/* { dg-options "-save-temps -O2 -fno-inline" } */
#include <string.h>
#include <stdlib.h>
#define LEN (100)
short a[LEN];
void
foo (void)
{
memset (a, -1, 7);
return;
}
void
check (signed char *arr, int idx, int len, int v)
{
int i;
for (i = 0; i < idx; i++)
if (arr[i] != v)
abort ();
for (i = idx; i < len; i++)
if (arr[i] != 0)
abort ();
}
int
main(void)
{
foo ();
check ((signed char *)a, 7, sizeof (a), -1);
return 0;
}
/* { dg-final { scan-assembler-not "bl?\[ \t\]*memset" { target { ! arm_thumb1_ok } } } } */
/* { dg-final { scan-assembler-not "strh" { target { arm_unaligned } } } } */
/* { dg-final { scan-assembler-not "strb" { target { arm_unaligned } } } } */
/* { dg-do run } */
/* { dg-skip-if "Don't inline memset using neon instructions on cortex-a9" { *-*-* } { "-mcpu=cortex-a9" } { "" } } */
/* { dg-skip-if "Don't inline memset using neon instructions on cortex-a9" { *-*-* } { "-mtune=cortex-a9" } { "" } } */
/* { dg-options "-save-temps -O2 -fno-inline" } */
/* { dg-add-options "arm_neon" } */
#include <string.h>
#include <stdlib.h>
#define LEN (100)
int a[LEN];
int b[LEN];
int c[LEN];
void
foo1 (void)
{
memset (a, -1, 8);
return;
}
void
foo2 (void)
{
memset (b, 1, 12);
return;
}
void
foo3 (void)
{
memset (c, 1, 13);
return;
}
void
check (signed char *arr, int idx, int len, int v)
{
int i;
for (i = 0; i < idx; i++)
if (arr[i] != v)
abort ();
for (i = idx; i < len; i++)
if (arr[i] != 0)
abort ();
}
int
main(void)
{
int i;
foo1 ();
check ((signed char *)a, 8, sizeof (a), -1);
foo2 ();
check ((signed char *)b, 12, sizeof (b), 1);
foo3 ();
check ((signed char *)c, 13, sizeof (c), 1);
return 0;
}
/* { dg-final { scan-assembler-not "bl?\[ \t\]+memset" { target { ! arm_thumb1_ok } } } } */
/* { dg-final { scan-assembler-times "vst1\.8" 1 { target { arm_little_endian && arm_neon } } } } */
/* { dg-final { scan-assembler "vstr" { target { arm_little_endian && arm_neon } } } } */
/* { dg-final { cleanup-saved-temps } } */
/* { dg-do run } */
/* { dg-skip-if "Don't inline memset using neon instructions on cortex-a9" { *-*-* } { "-mcpu=cortex-a9" } { "" } } */
/* { dg-skip-if "Don't inline memset using neon instructions on cortex-a9" { *-*-* } { "-mtune=cortex-a9" } { "" } } */
/* { dg-options "-save-temps -O2 -fno-inline" } */
/* { dg-add-options "arm_neon" } */
#include <string.h>
#include <stdlib.h>
#define LEN (100)
int a[LEN];
int b[LEN];
int c[LEN];
int d[LEN];
void
foo1 (void)
{
memset (a, -1, 16);
return;
}
void
foo2 (void)
{
memset (b, 1, 25);
return;
}
void
foo3 (void)
{
memset (c, -1, 19);
return;
}
void
foo4 (void)
{
memset (d, 1, 23);
return;
}
void
check (signed char *arr, int idx, int len, int v)
{
int i;
for (i = 0; i < idx; i++)
if (arr[i] != v)
abort ();
for (i = idx; i < len; i++)
if (arr[i] != 0)
abort ();
}
int
main(void)
{
foo1 ();
check ((signed char *)a, 16, sizeof (a), -1);
foo2 ();
check ((signed char *)b, 25, sizeof (b), 1);
foo3 ();
check ((signed char *)c, 19, sizeof (c), -1);
foo4 ();
check ((signed char *)d, 23, sizeof (d), 1);
return 0;
}
/* { dg-final { scan-assembler-not "bl?\[ \t\]+memset" { target { arm_little_endian && arm_neon } } } } */
/* { dg-final { scan-assembler "vst1" { target { arm_little_endian && arm_neon } } } } */
/* { dg-final { scan-assembler-not "vstr" { target { arm_little_endian && arm_neon } } } } */
/* { dg-final { cleanup-saved-temps } } */
/* { dg-do run } */
/* { dg-skip-if "Don't inline memset using neon instructions on cortex-a9" { *-*-* } { "-mcpu=cortex-a9" } { "" } } */
/* { dg-skip-if "Don't inline memset using neon instructions on cortex-a9" { *-*-* } { "-mtune=cortex-a9" } { "" } } */
/* { dg-options "-save-temps -O2 -fno-inline" } */
/* { dg-add-options "arm_neon" } */
#include <string.h>
#include <stdlib.h>
#define LEN (100)
int a[LEN];
int b[LEN];
int c[LEN];
void
foo1 (void)
{
memset (a, -1, 20);
return;
}
void
foo2 (void)
{
memset (b, 1, 24);
return;
}
void
foo3 (void)
{
memset (c, -1, 32);
return;
}
void
check (signed char *arr, int idx, int len, int v)
{
int i;
for (i = 0; i < idx; i++)
if (arr[i] != v)
abort ();
for (i = idx; i < len; i++)
if (arr[i] != 0)
abort ();
}
int
main(void)
{
foo1 ();
check ((signed char *)a, 20, sizeof (a), -1);
foo2 ();
check ((signed char *)b, 24, sizeof (b), 1);
foo3 ();
check ((signed char *)c, 32, sizeof (c), -1);
return 0;
}
/* { dg-final { scan-assembler-not "bl?\[ \t\]+memset" { target { arm_little_endian && arm_neon } } } } */
/* { dg-final { scan-assembler-times "vst1" 3 { target { arm_little_endian && arm_neon } } } } */
/* { dg-final { scan-assembler-times "vstr" 4 { target { arm_little_endian && arm_neon } } } } */
/* { dg-final { cleanup-saved-temps } } */
/* { dg-do run } */
/* { dg-options "-O2" } */
#include <string.h>
#include <stdlib.h>
#define LEN (100)
short a[LEN];
int b[LEN];
void
init (signed char *arr, int len)
{
int i;
for (i = 0; i < len; i++)
arr[i] = 0;
}
void
check (signed char *arr, int idx, int len, int v)
{
int i;
for (i = 0; i < idx; i++)
if (arr[i] != v)
abort ();
for (i = idx; i < len; i++)
if (arr[i] != 0)
abort ();
}
#define TEST(a,l,v) \
init ((signed char*)(a), sizeof (a)); \
memset ((a), (v), (l)); \
check ((signed char *)(a), (l), sizeof (a), (v));
int
main(void)
{
TEST (a, 1, -1);
TEST (a, 2, -1);
TEST (a, 3, -1);
TEST (a, 4, -1);
TEST (a, 5, -1);
TEST (a, 6, -1);
TEST (a, 7, -1);
TEST (a, 8, -1);
TEST (a, 9, 1);
TEST (a, 10, -1);
TEST (a, 11, 1);
TEST (a, 12, -1);
TEST (a, 13, 1);
TEST (a, 14, -1);
TEST (a, 15, 1);
TEST (a, 16, -1);
TEST (a, 17, 1);
TEST (a, 18, -1);
TEST (a, 19, 1);
TEST (a, 20, -1);
TEST (a, 21, 1);
TEST (a, 22, -1);
TEST (a, 23, 1);
TEST (a, 24, -1);
TEST (a, 25, 1);
TEST (a, 26, -1);
TEST (a, 27, 1);
TEST (a, 28, -1);
TEST (a, 29, 1);
TEST (a, 30, -1);
TEST (a, 31, 1);
TEST (a, 32, -1);
TEST (a, 33, 1);
TEST (a, 34, -1);
TEST (a, 35, 1);
TEST (a, 36, -1);
TEST (a, 37, 1);
TEST (a, 38, -1);
TEST (a, 39, 1);
TEST (a, 40, -1);
TEST (a, 41, 1);
TEST (a, 42, -1);
TEST (a, 43, 1);
TEST (a, 44, -1);
TEST (a, 45, 1);
TEST (a, 46, -1);
TEST (a, 47, 1);
TEST (a, 48, -1);
TEST (a, 49, 1);
TEST (a, 50, -1);
TEST (a, 51, 1);
TEST (a, 52, -1);
TEST (a, 53, 1);
TEST (a, 54, -1);
TEST (a, 55, 1);
TEST (a, 56, -1);
TEST (a, 57, 1);
TEST (a, 58, -1);
TEST (a, 59, 1);
TEST (a, 60, -1);
TEST (a, 61, 1);
TEST (a, 62, -1);
TEST (a, 63, 1);
TEST (a, 64, -1);
TEST (b, 1, -1);
TEST (b, 2, -1);
TEST (b, 3, -1);
TEST (b, 4, -1);
TEST (b, 5, -1);
TEST (b, 6, -1);
TEST (b, 7, -1);
TEST (b, 8, -1);
TEST (b, 9, 1);
TEST (b, 10, -1);
TEST (b, 11, 1);
TEST (b, 12, -1);
TEST (b, 13, 1);
TEST (b, 14, -1);
TEST (b, 15, 1);
TEST (b, 16, -1);
TEST (b, 17, 1);
TEST (b, 18, -1);
TEST (b, 19, 1);
TEST (b, 20, -1);
TEST (b, 21, 1);
TEST (b, 22, -1);
TEST (b, 23, 1);
TEST (b, 24, -1);
TEST (b, 25, 1);
TEST (b, 26, -1);
TEST (b, 27, 1);
TEST (b, 28, -1);
TEST (b, 29, 1);
TEST (b, 30, -1);
TEST (b, 31, 1);
TEST (b, 32, -1);
TEST (b, 33, 1);
TEST (b, 34, -1);
TEST (b, 35, 1);
TEST (b, 36, -1);
TEST (b, 37, 1);
TEST (b, 38, -1);
TEST (b, 39, 1);
TEST (b, 40, -1);
TEST (b, 41, 1);
TEST (b, 42, -1);
TEST (b, 43, 1);
TEST (b, 44, -1);
TEST (b, 45, 1);
TEST (b, 46, -1);
TEST (b, 47, 1);
TEST (b, 48, -1);
TEST (b, 49, 1);
TEST (b, 50, -1);
TEST (b, 51, 1);
TEST (b, 52, -1);
TEST (b, 53, 1);
TEST (b, 54, -1);
TEST (b, 55, 1);
TEST (b, 56, -1);
TEST (b, 57, 1);
TEST (b, 58, -1);
TEST (b, 59, 1);
TEST (b, 60, -1);
TEST (b, 61, 1);
TEST (b, 62, -1);
TEST (b, 63, 1);
TEST (b, 64, -1);
return 0;
}
/* { dg-do run } */
/* { dg-skip-if "Don't inline memset using neon instructions on cortex-a9" { *-*-* } { "-mcpu=cortex-a9" } { "" } } */
/* { dg-skip-if "Don't inline memset using neon instructions on cortex-a9" { *-*-* } { "-mtune=cortex-a9" } { "" } } */
/* { dg-options "-save-temps -O2 -fno-inline" } */
/* { dg-add-options "arm_neon" } */
#include <string.h>
#include <stdlib.h>
#define LEN (100)
short a[LEN];
void
foo (void)
{
memset (a, -1, 14);
return;
}
void
check (signed char *arr, int idx, int len, int v)
{
int i;
for (i = 0; i < idx; i++)
if (arr[i] != v)
abort ();
for (i = idx; i < len; i++)
if (arr[i] != 0)
abort ();
}
int
main(void)
{
foo ();
check ((signed char *)a, 14, sizeof (a), -1);
return 0;
}
/* { dg-final { scan-assembler-not "bl?\[ \t\]*memset" { target { arm_thumb2_ok } } } } */
/* { dg-final { scan-assembler "vst1" { target { arm_little_endian && arm_neon } } } } */
/* { dg-final { scan-assembler-not "vstr" { target { arm_little_endian && arm_neon } } } } */
/* { dg-final { cleanup-saved-temps } } */
/* { dg-do run } */
/* { dg-skip-if "Don't inline memset using neon instructions on cortex-a9" { *-*-* } { "-mcpu=cortex-a9" } { "" } } */
/* { dg-skip-if "Don't inline memset using neon instructions on cortex-a9" { *-*-* } { "-mtune=cortex-a9" } { "" } } */
/* { dg-options "-save-temps -Os -fno-inline" } */
/* { dg-add-options "arm_neon" } */
#include <string.h>
#include <stdlib.h>
#define LEN (100)
short a[LEN];
void
foo (void)
{
memset (a, -1, 14);
return;
}
void
check (signed char *arr, int idx, int len, int v)
{
int i;
for (i = 0; i < idx; i++)
if (arr[i] != v)
abort ();
for (i = idx; i < len; i++)
if (arr[i] != 0)
abort ();
}
int
main(void)
{
foo ();
check ((signed char *)a, 14, sizeof (a), -1);
return 0;
}
/* { dg-final { scan-assembler-not "bl?\[ \t\]*memset" { target { arm_little_endian && arm_neon } } } } */
/* { dg-final { scan-assembler "vst1" { target { arm_little_endian && arm_neon } } } } */
/* { dg-final { cleanup-saved-temps } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment