From f290100275139ccb59832bb75ff7fb2606e110d7 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 6 Jul 2018 23:42:41 +0200 Subject: re PR tree-optimization/86401 (The "For constants M and N, if M == (1LL << cst) - 1 && (N & M) == M,..." opts are only in fold-const.c and in RTL) PR tree-optimization/86401 * fold-const.c (fold_binary_loc) : Move the ((A & N) + B) & M -> (A + B) & M etc. optimization into ... (fold_bit_and_mask): ... here. New helper function for match.pd. * fold-const.h (fold_bit_and_mask): Declare. * match.pd (((A & N) + B) & M -> (A + B) & M): New optimization. * gcc.dg/tree-ssa/pr86401-1.c: New test. * gcc.dg/tree-ssa/pr86401-2.c: New test. * c-c++-common/rotate-9.c: New test. From-SVN: r262485 --- gcc/fold-const.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gcc/fold-const.h') diff --git a/gcc/fold-const.h b/gcc/fold-const.h index 337818a..c64b8d0 100644 --- a/gcc/fold-const.h +++ b/gcc/fold-const.h @@ -96,6 +96,9 @@ extern tree omit_two_operands_loc (location_t, tree, tree, tree, tree); extern tree invert_truthvalue_loc (location_t, tree); extern tree fold_unary_to_constant (enum tree_code, tree, tree); extern tree fold_binary_to_constant (enum tree_code, tree, tree, tree); +extern tree fold_bit_and_mask (tree, tree, enum tree_code, + tree, enum tree_code, tree, tree, + tree, enum tree_code, tree, tree, tree *); extern tree fold_read_from_constant_string (tree); extern tree int_const_binop (enum tree_code, const_tree, const_tree); #define build_fold_addr_expr(T)\ -- cgit v1.1