aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.h
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2021-10-28 20:10:15 +0200
committerJakub Jelinek <jakub@redhat.com>2021-10-28 20:10:15 +0200
commit6123b998b185572abac7d7224b34f03955bb91a2 (patch)
tree37da95c6b820de59031915d527b40bb48263829e /gcc/fold-const.h
parentd123daec0c237533cf974334d98bc6d357d4273e (diff)
downloadgcc-6123b998b185572abac7d7224b34f03955bb91a2.zip
gcc-6123b998b185572abac7d7224b34f03955bb91a2.tar.gz
gcc-6123b998b185572abac7d7224b34f03955bb91a2.tar.bz2
match.pd: Optimize MIN_EXPR <addr1, addr2> etc. addr1 < addr2 would be simplified [PR102951]
This patch outlines the decision whether address comparison can be folded or not from the match.pd simple comparison simplification and uses it both there and in a new minmax simplification, such that we fold e.g. MAX (&a[2], &a[1]) etc. Some of the Wstringop-overflow-62.c changes might look weird, but that seems to be mainly due to gimple_fold_builtin_memset not bothering to copy over location, will fix that incrementally. 2021-10-28 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/102951 * fold-const.h (address_compare): Declare. * fold-const.c (address_compare): New function. * match.pd (cmp (convert1?@2 addr@0) (convert2? addr@1)): Use address_compare helper. (minmax cmp (convert1?@2 addr@0) (convert2?@3 addr@1)): New simplification. * gcc.dg/tree-ssa/pr102951.c: New test. * gcc.dg/Wstringop-overflow-62.c: Adjust expected diagnostics.
Diffstat (limited to 'gcc/fold-const.h')
-rw-r--r--gcc/fold-const.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/fold-const.h b/gcc/fold-const.h
index 7bac84b..fed4768 100644
--- a/gcc/fold-const.h
+++ b/gcc/fold-const.h
@@ -213,6 +213,8 @@ extern bool negate_mathfn_p (combined_fn);
extern const char *getbyterep (tree, unsigned HOST_WIDE_INT *);
extern const char *c_getstr (tree);
extern wide_int tree_nonzero_bits (const_tree);
+extern int address_compare (tree_code, tree, tree, tree, tree &, tree &,
+ poly_int64 &, poly_int64 &, bool);
/* Return OFF converted to a pointer offset type suitable as offset for
POINTER_PLUS_EXPR. Use location LOC for this conversion. */