+2015-06-09 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/66423
+ * match.pd: Handle A % (unsigned)(1 << B).
+
2015-06-09 Aldy Hernandez <aldyh@redhat.com>
* varasm.c (output_object_block_htab): Remove.
(lshift INTEGER_CST@1 @2))
(for mod (trunc_mod floor_mod)
(simplify
- (mod @0 (power_of_two_cand@1 @2))
+ (mod @0 (convert?@3 (power_of_two_cand@1 @2)))
(if ((TYPE_UNSIGNED (type)
|| tree_expr_nonnegative_p (@0))
+ && tree_nop_conversion_p (type, TREE_TYPE (@3))
&& integer_pow2p (@2) && tree_int_cst_sgn (@2) > 0)
- (bit_and @0 (minus @1 { build_int_cst (TREE_TYPE (@1), 1); })))))
+ (bit_and @0 (convert (minus @1 { build_int_cst (TREE_TYPE (@1), 1); }))))))
/* X % Y is smaller than Y. */
(for cmp (lt ge)
+2015-06-09 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/66423
+ * gcc.dg/fold-modpow2.c: New testcase.
+
2015-06-09 Richard Biener <rguenther@suse.de>
PR tree-optimization/66419
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-original" } */
+
+unsigned int
+my_mod (unsigned int a, unsigned int b)
+{
+ return a % (1 << b);
+}
+
+/* The above should be simplified to (unsigned int) ((1 << b) + -1) & a */
+/* { dg-final { scan-tree-dump "& a;" "original" } } */