> -----Original Message-----
> From: Hu, Lin1 <lin1...@intel.com>
> Sent: Tuesday, November 5, 2024 1:34 PM
> To: gcc-patches@gcc.gnu.org
> Cc: Liu, Hongtao <hongtao....@intel.com>; ubiz...@gmail.com
> Subject: [PATCH v2] i386: Handling exception input of
> __builtin_ia32_prefetch. [PR117416]
> 
> Add handler for op3, and the previously stated fail is a random fail not 
> related
> to this change, OK for trunk?
>

The fail mentioned here is gcc.dg/tortune/convert-dfp.c triggered by test 
environment

Its output is "i386 architecture of input file `./convert-dfp.ltrans0.ltrans.o' 
is incompatible with i386:x86-64 output."

When I test my patch in another test environment, the fail disappeared, it 
looks like the fail isn't related to this patch from
the test result and the output. I think this part of the change is safe.

BRs,
Lin

> 
> op1 should be between 0 and 2. Add an error handler, and op3 should be 0 or
> 1, raise a warning, when op3 is an invalid value.
> 
> gcc/ChangeLog:
> 
>       PR target/117416
>       * config/i386/i386-expand.cc (ix86_expand_builtin): Raise warning
> when
>       op1 isn't in range of [0, 2] and set op1 as const0_rtx, and raise
>       warning when op3 isn't in range of [0, 1].
> 
> gcc/testsuite/ChangeLog:
> 
>       PR target/117416
>       * gcc.target/i386/pr117416-1.c: New test.
>       * gcc.target/i386/pr117416-2.c: Ditto.
> ---
>  gcc/config/i386/i386-expand.cc             | 11 +++++++++++
>  gcc/testsuite/gcc.target/i386/pr117416-1.c | 12 ++++++++++++
> gcc/testsuite/gcc.target/i386/pr117416-2.c | 12 ++++++++++++
>  3 files changed, 35 insertions(+)
>  create mode 100644 gcc/testsuite/gcc.target/i386/pr117416-1.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/pr117416-2.c
> 
> diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
> index 515334aa5a3..fcd4b3b67b7 100644
> --- a/gcc/config/i386/i386-expand.cc
> +++ b/gcc/config/i386/i386-expand.cc
> @@ -14194,6 +14194,13 @@ ix86_expand_builtin (tree exp, rtx target, rtx
> subtarget,
>           return const0_rtx;
>         }
> 
> +     if (!IN_RANGE (INTVAL (op1), 0, 2))
> +       {
> +         warning (0, "invalid second argument to"
> +                  " %<__builtin_ia32_prefetch%>; using zero");
> +         op1 = const0_rtx;
> +       }
> +
>       if (INTVAL (op3) == 1)
>         {
>           if (INTVAL (op2) < 2 || INTVAL (op2) > 3) @@ -14216,6 +14223,10
> @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
>         }
>       else
>         {
> +         if (INTVAL (op3) != 0)
> +           warning (0, "invalid forth argument to"
> +                       " %<__builtin_ia32_prefetch%>; using zero");
> +
>           if (!address_operand (op0, VOIDmode))
>             {
>               op0 = convert_memory_address (Pmode, op0); diff --git
> a/gcc/testsuite/gcc.target/i386/pr117416-1.c
> b/gcc/testsuite/gcc.target/i386/pr117416-1.c
> new file mode 100644
> index 00000000000..7062f27e21a
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr117416-1.c
> @@ -0,0 +1,12 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O0" } */
> +
> +#include <x86intrin.h>
> +
> +void* p;
> +
> +void extern
> +prefetch_test (void)
> +{
> +  __builtin_ia32_prefetch (p, 5, 0, 0); /* { dg-warning "invalid second
> +argument to '__builtin_ia32_prefetch'; using zero" } */ }
> diff --git a/gcc/testsuite/gcc.target/i386/pr117416-2.c
> b/gcc/testsuite/gcc.target/i386/pr117416-2.c
> new file mode 100644
> index 00000000000..1397645cbfc
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr117416-2.c
> @@ -0,0 +1,12 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O0" } */
> +
> +#include <x86intrin.h>
> +
> +void* p;
> +
> +void extern
> +prefetch_test (void)
> +{
> +  __builtin_ia32_prefetch (p, 0, 0, 2); /* { dg-warning "invalid forth
> +argument to '__builtin_ia32_prefetch'; using zero" } */ }
> --
> 2.31.1

Reply via email to