On Sat, Sep 5, 2026 at 8:35 AM wangjue <[email protected]> wrote:
>
> From: juewang <[email protected]>
>
> m68k_sched_issue_rate can be called for targets without a scheduling
> model.  Return 1 for those targets instead of calling gcc_unreachable.
>
> Add tests for if-conversion costing on single-issue and multi-issue
> targets.
>
> Assisted-by: Codex (OpenAI)
>
> gcc/ChangeLog:
>
>         * config/m68k/m68k.cc (m68k_sched_issue_rate): Return one for CPUs
>         without a scheduling model.

Need a generic test which triggers ICE without the change.

> gcc/testsuite/ChangeLog:
>
>         * gcc.target/riscv/ifcvt-parallel-cost-1.c: New test.
>         * gcc.target/riscv/ifcvt-parallel-cost-2.c: Likewise.
> ---
>  gcc/config/m68k/m68k.cc                       |  3 +-
>  .../gcc.target/riscv/ifcvt-parallel-cost-1.c  | 26 +++++++++++++++++
>  .../gcc.target/riscv/ifcvt-parallel-cost-2.c  | 29 +++++++++++++++++++
>  3 files changed, 56 insertions(+), 2 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/riscv/ifcvt-parallel-cost-1.c
>  create mode 100644 gcc/testsuite/gcc.target/riscv/ifcvt-parallel-cost-2.c
>
> diff --git a/gcc/config/m68k/m68k.cc b/gcc/config/m68k/m68k.cc
> index b6134892883..074d82efb25 100644
> --- a/gcc/config/m68k/m68k.cc
> +++ b/gcc/config/m68k/m68k.cc
> @@ -6594,8 +6594,7 @@ m68k_sched_issue_rate (void)
>        return 2;
>
>      default:
> -      gcc_unreachable ();
> -      return 0;
> +      return 1;
>      }
>  }
>
> diff --git a/gcc/testsuite/gcc.target/riscv/ifcvt-parallel-cost-1.c 
> b/gcc/testsuite/gcc.target/riscv/ifcvt-parallel-cost-1.c
> new file mode 100644
> index 00000000000..1bec3f77dcd
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/riscv/ifcvt-parallel-cost-1.c
> @@ -0,0 +1,26 @@
> +/* { dg-do compile } */
> +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */
> +/* { dg-options "-O2 -march=rv64gc_zicond -mabi=lp64d -mtune=xt-c9501fdvt 
> -mbranch-cost=3" } */
> +
> +extern void consume (void *, void *, void *);
> +
> +__attribute__ ((noinline, noclone))
> +void
> +select_three_pointers (long x, long y,
> +                      void *a0, void *a1,
> +                      void *b0, void *b1,
> +                      void *c0, void *c1)
> +{
> +  if (x > y)
> +    {
> +      a0 = a1;
> +      b0 = b1;
> +      c0 = c1;
> +    }
> +
> +  consume (a0, b0, c0);
> +}
> +
> +/* { dg-final { scan-assembler-times "\\sczero\\.eqz\\s" 3 } } */
> +/* { dg-final { scan-assembler-times "\\sczero\\.nez\\s" 3 } } */
> +/* { dg-final { scan-assembler-not "\\s(?:bge|bgt|ble|blt)\\s" } } */
> diff --git a/gcc/testsuite/gcc.target/riscv/ifcvt-parallel-cost-2.c 
> b/gcc/testsuite/gcc.target/riscv/ifcvt-parallel-cost-2.c
> new file mode 100644
> index 00000000000..6e1f9ed7849
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/riscv/ifcvt-parallel-cost-2.c
> @@ -0,0 +1,29 @@
> +/* { dg-do compile } */
> +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */
> +/* { dg-options "-O2 -march=rv64gc_zicond -mabi=lp64d -mtune=generic 
> -mbranch-cost=3" } */
> +
> +extern void consume (void *, void *, void *);
> +
> +__attribute__ ((noinline, noclone))
> +void
> +select_three_pointers_generic (long x, long y,
> +                              void *a0, void *a1,
> +                              void *b0, void *b1,
> +                              void *c0, void *c1)
> +{
> +  if (x >= y)
> +    {
> +      a0 = a1;
> +      b0 = b1;
> +      c0 = c1;
> +    }
> +
> +  consume (a0, b0, c0);
> +}
> +
> +/* The generic tuning model has an issue rate of one, so the three pointer
> +   selections are not profitable at a branch cost of three.  */
> +
> +/* { dg-final { scan-assembler-times "\\sbge\\s" 1 } } */
> +/* { dg-final { scan-assembler-not "\\sczero\\.eqz\\s" } } */
> +/* { dg-final { scan-assembler-not "\\sczero\\.nez\\s" } } */
> --
> 2.34.1
>


-- 
H.J.

Reply via email to