aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-match-head.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2021-04-27 14:47:54 +0200
committerJakub Jelinek <jakub@redhat.com>2021-04-27 14:47:54 +0200
commit75f8900159133ce069ef1d2edf3b67c7bc82e305 (patch)
tree9e267659619ba04d9dbbc58c462abe08fec770a8 /gcc/gimple-match-head.c
parent3dcd1334b4f522352b80814513fdca902fc2a207 (diff)
downloadgcc-75f8900159133ce069ef1d2edf3b67c7bc82e305.zip
gcc-75f8900159133ce069ef1d2edf3b67c7bc82e305.tar.gz
gcc-75f8900159133ce069ef1d2edf3b67c7bc82e305.tar.bz2
match.pd: Add some __builtin_ctz (x) cmp cst simplifications [PR95527]
This patch adds some ctz simplifications (e.g. ctz (x) >= 3 can be done by testing if the low 3 bits are zero, etc.). In addition, I've noticed that in the CLZ case, the #ifdef CLZ_DEFINED_VALUE_AT_ZERO don't really work as intended, they are evaluated during genmatch and the macro is not defined then (but, because of the missing tm.h includes it isn't defined in gimple-match.c or generic-match.c either). And when tm.h is included, defaults.h is included which defines a fallback version of that macro. For GCC 12, I wonder if it wouldn't be better to say in addition to __builtin_c[lt]z* is always UB at zero that it would be undefined for .C[LT]Z ifn too if it has just one operand and use a second operand to be the constant we expect at zero. 2021-04-27 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/95527 * generic-match-head.c: Include tm.h. * gimple-match-head.c: Include tm.h. * match.pd (CLZ == INTEGER_CST): Don't use #ifdef CLZ_DEFINED_VALUE_AT_ZERO, only test CLZ_DEFINED_VALUE_AT_ZERO if clz == CFN_CLZ. Add missing val declaration. (CTZ cmp CST): New simplifications. * gcc.dg/tree-ssa/pr95527-2.c: New test.
Diffstat (limited to 'gcc/gimple-match-head.c')
-rw-r--r--gcc/gimple-match-head.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/gimple-match-head.c b/gcc/gimple-match-head.c
index 84fbaef..b084a3157 100644
--- a/gcc/gimple-match-head.c
+++ b/gcc/gimple-match-head.c
@@ -43,6 +43,7 @@ along with GCC; see the file COPYING3. If not see
#include "optabs-tree.h"
#include "tree-eh.h"
#include "dbgcnt.h"
+#include "tm.h"
/* Forward declarations of the private auto-generated matchers.
They expect valueized operands in canonical order and do not