aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-11-01 23:03:48 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2024-11-01 23:03:48 +0100
commit115ab8d7ad33a7f500460dc5af28f6912ddfb91c (patch)
tree71bb9b1df003540986728fd2045fc48c82671688
parent1a5bdeb1128ecfa4ce233218d02ccbb88ce0d8a8 (diff)
downloadgcc-115ab8d7ad33a7f500460dc5af28f6912ddfb91c.zip
gcc-115ab8d7ad33a7f500460dc5af28f6912ddfb91c.tar.gz
gcc-115ab8d7ad33a7f500460dc5af28f6912ddfb91c.tar.bz2
builtins: Fix expand_builtin_prefetch [PR117407]
On Fri, Nov 01, 2024 at 04:47:35PM +0800, Haochen Jiang wrote: > * builtins.cc (expand_builtin_prefetch): Use IN_RANGE to > avoid second usage of INTVAL. I doubt this has been actually tested. > --- a/gcc/builtins.cc > +++ b/gcc/builtins.cc > @@ -1297,7 +1297,7 @@ expand_builtin_prefetch (tree exp) > else > op1 = expand_normal (arg1); > /* Argument 1 must be 0, 1 or 2. */ > - if (INTVAL (op1) < 0 || INTVAL (op1) > 2) > + if (IN_RANGE (INTVAL (op1), 0, 2)) > { > warning (0, "invalid second argument to %<__builtin_prefetch%>;" > " using zero"); > @@ -1315,7 +1315,7 @@ expand_builtin_prefetch (tree exp) > else > op2 = expand_normal (arg2); > /* Argument 2 must be 0, 1, 2, or 3. */ > - if (INTVAL (op2) < 0 || INTVAL (op2) > 3) > + if (IN_RANGE (INTVAL (op2), 0, 3)) > { > warning (0, "invalid third argument to %<__builtin_prefetch%>; using zero"); > op2 = const0_rtx; because it inverts the tests, previously it was warning when op1 wasn't 0, 1, 2, now it warns when it is 0, 1 or 2, previously it was warning when op2 wasn't 0, 1, 2 or 3, now it warns when it is 0, 1, 2, or 3. Fixed thusly. 2024-11-01 Jakub Jelinek <jakub@redhat.com> PR bootstrap/117407 * builtins.cc (expand_builtin_prefetch): Use !IN_RANGE rather than IN_RANGE.
-rw-r--r--gcc/builtins.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index b868441..0d90c2a 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -1297,7 +1297,7 @@ expand_builtin_prefetch (tree exp)
else
op1 = expand_normal (arg1);
/* Argument 1 must be 0, 1 or 2. */
- if (IN_RANGE (INTVAL (op1), 0, 2))
+ if (!IN_RANGE (INTVAL (op1), 0, 2))
{
warning (0, "invalid second argument to %<__builtin_prefetch%>;"
" using zero");
@@ -1315,7 +1315,7 @@ expand_builtin_prefetch (tree exp)
else
op2 = expand_normal (arg2);
/* Argument 2 must be 0, 1, 2, or 3. */
- if (IN_RANGE (INTVAL (op2), 0, 3))
+ if (!IN_RANGE (INTVAL (op2), 0, 3))
{
warning (0, "invalid third argument to %<__builtin_prefetch%>; using zero");
op2 = const0_rtx;