mirror of git://gcc.gnu.org/git/gcc.git
aarch64.c (aarch64_rtx_costs): Make sdiv more expensive than udiv.
2017-06-07 Tamar Christina <tamar.christina@arm.com> * config/aarch64/aarch64.c (aarch64_rtx_costs): Make sdiv more expensive than udiv. Remove floating point cases from mod. From-SVN: r248953
This commit is contained in:
parent
e059725b24
commit
cb9ac430cb
|
|
@ -1,3 +1,8 @@
|
||||||
|
2017-06-07 Tamar Christina <tamar.christina@arm.com>
|
||||||
|
|
||||||
|
* config/aarch64/aarch64.c (aarch64_rtx_costs): Make sdiv more expensive than udiv.
|
||||||
|
Remove floating point cases from mod.
|
||||||
|
|
||||||
2017-06-07 Tamar Christina <tamar.christina@arm.com>
|
2017-06-07 Tamar Christina <tamar.christina@arm.com>
|
||||||
|
|
||||||
* config/arm/aarch-cost-tables.h (cortexa53_extra_cost): Increase idiv cost.
|
* config/arm/aarch-cost-tables.h (cortexa53_extra_cost): Increase idiv cost.
|
||||||
|
|
|
||||||
|
|
@ -7544,17 +7544,13 @@ cost_plus:
|
||||||
case UMOD:
|
case UMOD:
|
||||||
if (speed)
|
if (speed)
|
||||||
{
|
{
|
||||||
|
/* Slighly prefer UMOD over SMOD. */
|
||||||
if (VECTOR_MODE_P (mode))
|
if (VECTOR_MODE_P (mode))
|
||||||
*cost += extra_cost->vect.alu;
|
*cost += extra_cost->vect.alu;
|
||||||
else if (GET_MODE_CLASS (mode) == MODE_INT)
|
else if (GET_MODE_CLASS (mode) == MODE_INT)
|
||||||
*cost += (extra_cost->mult[mode == DImode].add
|
*cost += (extra_cost->mult[mode == DImode].add
|
||||||
+ extra_cost->mult[mode == DImode].idiv);
|
+ extra_cost->mult[mode == DImode].idiv
|
||||||
else if (mode == DFmode)
|
+ (code == MOD ? 1 : 0));
|
||||||
*cost += (extra_cost->fp[1].mult
|
|
||||||
+ extra_cost->fp[1].div);
|
|
||||||
else if (mode == SFmode)
|
|
||||||
*cost += (extra_cost->fp[0].mult
|
|
||||||
+ extra_cost->fp[0].div);
|
|
||||||
}
|
}
|
||||||
return false; /* All arguments need to be in registers. */
|
return false; /* All arguments need to be in registers. */
|
||||||
|
|
||||||
|
|
@ -7568,7 +7564,9 @@ cost_plus:
|
||||||
else if (GET_MODE_CLASS (mode) == MODE_INT)
|
else if (GET_MODE_CLASS (mode) == MODE_INT)
|
||||||
/* There is no integer SQRT, so only DIV and UDIV can get
|
/* There is no integer SQRT, so only DIV and UDIV can get
|
||||||
here. */
|
here. */
|
||||||
*cost += extra_cost->mult[mode == DImode].idiv;
|
*cost += (extra_cost->mult[mode == DImode].idiv
|
||||||
|
/* Slighly prefer UDIV over SDIV. */
|
||||||
|
+ (code == DIV ? 1 : 0));
|
||||||
else
|
else
|
||||||
*cost += extra_cost->fp[mode == DFmode].div;
|
*cost += extra_cost->fp[mode == DFmode].div;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
2017-06-07 Tamar Christina <tamar.christina@arm.com>
|
||||||
|
|
||||||
|
* gcc.target/aarch64/sdiv_costs_1.c: New.
|
||||||
|
|
||||||
2017-06-07 Richard Biener <rguenther@suse.de>
|
2017-06-07 Richard Biener <rguenther@suse.de>
|
||||||
|
|
||||||
PR tree-optimization/80928
|
PR tree-optimization/80928
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
/* { dg-do compile } */
|
||||||
|
/* { dg-options "-O3" } */
|
||||||
|
|
||||||
|
/* Both sdiv and udiv can be used here, so prefer udiv. */
|
||||||
|
int f1 (unsigned char *p)
|
||||||
|
{
|
||||||
|
return 100 / p[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
int f2 (unsigned char *p, unsigned short x)
|
||||||
|
{
|
||||||
|
return x / p[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
int f3 (unsigned char *p, int x)
|
||||||
|
{
|
||||||
|
x &= 0x7fffffff;
|
||||||
|
return x / p[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
int f5 (unsigned char *p, unsigned short x)
|
||||||
|
{
|
||||||
|
return x % p[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This should only generate signed divisions. */
|
||||||
|
int f4 (unsigned char *p)
|
||||||
|
{
|
||||||
|
return -100 / p[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
int f6 (unsigned char *p, short x)
|
||||||
|
{
|
||||||
|
return x % p[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* { dg-final { scan-assembler-times "udiv\tw\[0-9\]+, w\[0-9\]+" 4 } } */
|
||||||
|
/* { dg-final { scan-assembler-times "sdiv\tw\[0-9\]+, w\[0-9\]+" 2 } } */
|
||||||
Loading…
Reference in New Issue