[PATCH, GCC/ARM, stage4] Fix small multiply feature
Small multiply variants of ARM Cortex-M0, Cortex-M0+ and Cortex-M1 were relying on the old cost model to work when optimizing for speed. These stopped being used in r241965 which led to these cores starting to use mul instructions instead of synthetizing the multiplications. This was not caught by the testsuite because the test only run if RUNTESTFLAGS targets one of the small multiply implementations. This commit add the small multiply cost logic to the new speed cost model and change the dejagnu directives to only skip the corresponding tests if targeting another CPU. This means running the testsuite without targeting any CPU will let these tests run. ChangeLog entries are as follow: *** gcc/ChangeLog *** 2017-03-31 Thomas Preud'homme PR target/80307 * config/arm/arm.c (thumb1_rtx_costs): Give a cost of 32 instructions for small multiply cores. *** gcc/testsuite/ChangeLog *** 2017-03-31 Thomas Preud'homme PR target/80307 * gcc.target/arm/small-multiply-m0-1.c: Do not skip test if not targeting any CPU or architecture. * gcc.target/arm/small-multiply-m0-2.c: Likewise. * gcc.target/arm/small-multiply-m0-3.c: Likewise. * gcc.target/arm/small-multiply-m0plus-1.c: Likewise. * gcc.target/arm/small-multiply-m0plus-2.c: Likewise. * gcc.target/arm/small-multiply-m0plus-3.c: Likewise. * gcc.target/arm/small-multiply-m1-1.c: Likewise. * gcc.target/arm/small-multiply-m1-2.c: Likewise. * gcc.target/arm/small-multiply-m1-3.c: Likewise. Testing: With this patch the tests now all PASS if not targeting a special architecture or CPU. They were all UNSUPPORTED before in the same situation and the -1 tests were FAILing if targeting small multiply cores. Is this ok for stage4? Best regards, Thomas diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index b24143e32e2f10f3b150f7ed0df4fabb3cc8..33146d1f0b54bad16cdaca1902d0f0a06a18c89d 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -8727,6 +8727,9 @@ thumb1_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer) return COSTS_N_INSNS (1); case MULT: + if (arm_arch6m && arm_m_profile_small_mul) + return COSTS_N_INSNS (32); + if (CONST_INT_P (XEXP (x, 1))) { int cycles = 0; diff --git a/gcc/testsuite/gcc.target/arm/small-multiply-m0-1.c b/gcc/testsuite/gcc.target/arm/small-multiply-m0-1.c index 49132e3e83d42874385523a3d0f05522a5974113..52c652c1cba3729c121d613bdb8c9f3524b04c98 100644 --- a/gcc/testsuite/gcc.target/arm/small-multiply-m0-1.c +++ b/gcc/testsuite/gcc.target/arm/small-multiply-m0-1.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* { dg-require-effective-target arm_thumb1_ok } */ -/* { dg-skip-if "Test is specific to cortex-m0.small-multiply" { arm*-*-* } { "*" } { "-mcpu=cortex-m0.small-multiply" } } */ +/* { dg-skip-if "do not override -mcpu" { *-*-* } { "-mcpu=*" "-march=*" } { "-mcpu=cortex-m0.small-multiply" } } */ /* { dg-options "-mcpu=cortex-m0.small-multiply -mthumb -O2" } */ int diff --git a/gcc/testsuite/gcc.target/arm/small-multiply-m0-2.c b/gcc/testsuite/gcc.target/arm/small-multiply-m0-2.c index 7f1bf7bd604fcd6ef63f8dcb1fda0645d4803e87..10d49e9eace6141a5d3c906e235b6bbddaed8b4e 100644 --- a/gcc/testsuite/gcc.target/arm/small-multiply-m0-2.c +++ b/gcc/testsuite/gcc.target/arm/small-multiply-m0-2.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* { dg-require-effective-target arm_thumb1_ok } */ -/* { dg-skip-if "Test is specific to cortex-m0.small-multiply" { arm*-*-* } { "*" } { "-mcpu=cortex-m0.small-multiply" } } */ +/* { dg-skip-if "do not override -mcpu" { *-*-* } { "-mcpu=*" "-march=*" } { "-mcpu=cortex-m0.small-multiply" } } */ /* { dg-options "-mcpu=cortex-m0.small-multiply -mthumb -Os" } */ int diff --git a/gcc/testsuite/gcc.target/arm/small-multiply-m0-3.c b/gcc/testsuite/gcc.target/arm/small-multiply-m0-3.c index aca39d746dc83ec94dce4d690bf1b87370192e94..b4af511af86c88a6d98a2779b3dc808d2163380c 100644 --- a/gcc/testsuite/gcc.target/arm/small-multiply-m0-3.c +++ b/gcc/testsuite/gcc.target/arm/small-multiply-m0-3.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* { dg-require-effective-target arm_thumb1_ok } */ -/* { dg-skip-if "Test is specific to cortex-m0.small-multiply" { arm*-*-* } { "*" } { "-mcpu=cortex-m0.small-multiply" } } */ +/* { dg-skip-if "do not override -mcpu" { *-*-* } { "-mcpu=*" "-march=*" } { "-mcpu=cortex-m0.small-multiply" } } */ /* { dg-options "-mcpu=cortex-m0.small-multiply -mthumb -Os" } */ int diff --git a/gcc/testsuite/gcc.target/arm/small-multiply-m0plus-1.c b/gcc/testsuite/gcc.target/arm/small-multiply-m0plus-1.c index 12e8839753c3cd01e466cf61860236ff425c4e90..59dba7cf4abc814f0ee2cf9c4776d76d644a07fc 100644 --- a/gcc/testsuite/gcc.target/arm/small-multiply-m0plus-1.c +++ b/gcc/testsuite/gcc.target/arm/small-multiply-m0plus-1.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* { dg-require-effective-target arm_thumb1_ok } */ -/* { dg-skip
Re: [PATCH, GCC/ARM, stage4] Fix small multiply feature
On 04/04/17 11:30, Thomas Preudhomme wrote: > Small multiply variants of ARM Cortex-M0, Cortex-M0+ and Cortex-M1 were > relying on the old cost model to work when optimizing for speed. These > stopped being used in r241965 which led to these cores starting to use > mul instructions instead of synthetizing the multiplications. This was > not caught by the testsuite because the test only run if RUNTESTFLAGS > targets one of the small multiply implementations. > > This commit add the small multiply cost logic to the new speed cost > model and change the dejagnu directives to only skip the corresponding > tests if targeting another CPU. This means running the testsuite without > targeting any CPU will let these tests run. > > ChangeLog entries are as follow: > > *** gcc/ChangeLog *** > > 2017-03-31 Thomas Preud'homme > > PR target/80307 > * config/arm/arm.c (thumb1_rtx_costs): Give a cost of 32 > instructions for small multiply cores. > > > *** gcc/testsuite/ChangeLog *** > > 2017-03-31 Thomas Preud'homme > > PR target/80307 > * gcc.target/arm/small-multiply-m0-1.c: Do not skip test if not > targeting any CPU or architecture. > * gcc.target/arm/small-multiply-m0-2.c: Likewise. > * gcc.target/arm/small-multiply-m0-3.c: Likewise. > * gcc.target/arm/small-multiply-m0plus-1.c: Likewise. > * gcc.target/arm/small-multiply-m0plus-2.c: Likewise. > * gcc.target/arm/small-multiply-m0plus-3.c: Likewise. > * gcc.target/arm/small-multiply-m1-1.c: Likewise. > * gcc.target/arm/small-multiply-m1-2.c: Likewise. > * gcc.target/arm/small-multiply-m1-3.c: Likewise. > > Testing: With this patch the tests now all PASS if not targeting a > special architecture or CPU. They were all UNSUPPORTED before in the > same situation and the -1 tests were FAILing if targeting small > multiply cores. > > Is this ok for stage4? > OK. R. > Best regards, > > Thomas > > fix_pr80307_arm_small_multiply.patch > > > diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c > index > b24143e32e2f10f3b150f7ed0df4fabb3cc8..33146d1f0b54bad16cdaca1902d0f0a06a18c89d > 100644 > --- a/gcc/config/arm/arm.c > +++ b/gcc/config/arm/arm.c > @@ -8727,6 +8727,9 @@ thumb1_rtx_costs (rtx x, enum rtx_code code, enum > rtx_code outer) >return COSTS_N_INSNS (1); > > case MULT: > + if (arm_arch6m && arm_m_profile_small_mul) > + return COSTS_N_INSNS (32); > + >if (CONST_INT_P (XEXP (x, 1))) > { > int cycles = 0; > diff --git a/gcc/testsuite/gcc.target/arm/small-multiply-m0-1.c > b/gcc/testsuite/gcc.target/arm/small-multiply-m0-1.c > index > 49132e3e83d42874385523a3d0f05522a5974113..52c652c1cba3729c121d613bdb8c9f3524b04c98 > 100644 > --- a/gcc/testsuite/gcc.target/arm/small-multiply-m0-1.c > +++ b/gcc/testsuite/gcc.target/arm/small-multiply-m0-1.c > @@ -1,6 +1,6 @@ > /* { dg-do compile } */ > /* { dg-require-effective-target arm_thumb1_ok } */ > -/* { dg-skip-if "Test is specific to cortex-m0.small-multiply" { arm*-*-* } > { "*" } { "-mcpu=cortex-m0.small-multiply" } } */ > +/* { dg-skip-if "do not override -mcpu" { *-*-* } { "-mcpu=*" "-march=*" } { > "-mcpu=cortex-m0.small-multiply" } } */ > /* { dg-options "-mcpu=cortex-m0.small-multiply -mthumb -O2" } */ > > int > diff --git a/gcc/testsuite/gcc.target/arm/small-multiply-m0-2.c > b/gcc/testsuite/gcc.target/arm/small-multiply-m0-2.c > index > 7f1bf7bd604fcd6ef63f8dcb1fda0645d4803e87..10d49e9eace6141a5d3c906e235b6bbddaed8b4e > 100644 > --- a/gcc/testsuite/gcc.target/arm/small-multiply-m0-2.c > +++ b/gcc/testsuite/gcc.target/arm/small-multiply-m0-2.c > @@ -1,6 +1,6 @@ > /* { dg-do compile } */ > /* { dg-require-effective-target arm_thumb1_ok } */ > -/* { dg-skip-if "Test is specific to cortex-m0.small-multiply" { arm*-*-* } > { "*" } { "-mcpu=cortex-m0.small-multiply" } } */ > +/* { dg-skip-if "do not override -mcpu" { *-*-* } { "-mcpu=*" "-march=*" } { > "-mcpu=cortex-m0.small-multiply" } } */ > /* { dg-options "-mcpu=cortex-m0.small-multiply -mthumb -Os" } */ > > int > diff --git a/gcc/testsuite/gcc.target/arm/small-multiply-m0-3.c > b/gcc/testsuite/gcc.target/arm/small-multiply-m0-3.c > index > aca39d746dc83ec94dce4d690bf1b87370192e94..b4af511af86c88a6d98a2779b3dc808d2163380c > 100644 > --- a/gcc/testsuite/gcc.target/arm/small-multiply-m0-3.c > +++ b/gcc/testsuite/gcc.target/arm/small-multiply-m0-3.c > @@ -1,6 +1,6 @@ > /* { dg-do compile } */ > /* { dg-require-effective-target arm_thumb1_ok } */ > -/* { dg-skip-if "Test is specific to cortex-m0.small-multiply" { arm*-*-* } > { "*" } { "-mcpu=cortex-m0.small-multiply" } } */ > +/* { dg-skip-if "do not override -mcpu" { *-*-* } { "-mcpu=*" "-march=*" } { > "-mcpu=cortex-m0.small-multiply" } } */ > /* { dg-options "-mcpu=cortex-m0.small-multiply -mthumb -Os" } */ > > int > diff --git a/gcc/testsuite/gcc.target/arm/small-multiply-m0plus-1.c > b/gcc/testsuite/gcc.target/arm/small-multiply-m0plus-1.c > index >