+2019-06-06 Martin Liska <mliska@suse.cz>
+
+ PR tree-optimization/87954
+ * match.pd: Simplify mult where both arguments are 0 or 1.
+
2019-06-06 Richard Biener <rguenther@suse.de>
* vr-values.c (vr_values::extract_range_from_ssa_name): Do not
|| !COMPLEX_FLOAT_TYPE_P (type)))
(negate @0)))
+/* Transform { 0 or 1 } * { 0 or 1 } into { 0 or 1 } & { 0 or 1 } */
+(simplify
+ (mult SSA_NAME@1 SSA_NAME@2)
+ (if (INTEGRAL_TYPE_P (type)
+ && get_nonzero_bits (@1) == 1
+ && get_nonzero_bits (@2) == 1)
+ (bit_and @1 @2)))
+
/* Transform x * { 0 or 1, 0 or 1, ... } into x & { 0 or -1, 0 or -1, ...},
unless the target has native support for the former but not the latter. */
(simplify
+2019-06-06 Martin Liska <mliska@suse.cz>
+
+ PR tree-optimization/87954
+ * gcc.dg/pr87954.c: New test.
+
2019-06-06 Richard Biener <rguenther@suse.de>
* gcc.dg/tree-ssa/alias-37.c: New testcase.
--- /dev/null
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+#define __GFP_DMA 1u
+#define __GFP_RECLAIM 0x10u
+
+#define KMALLOC_DMA 2
+#define KMALLOC_RECLAIM 1
+
+unsigned int
+imul(unsigned int flags)
+{
+ int is_dma, type_dma, is_rec;
+
+ is_dma = !!(flags & __GFP_DMA);
+ type_dma = is_dma * KMALLOC_DMA;
+ is_rec = !!(flags & __GFP_RECLAIM);
+
+ return type_dma + (is_rec * !is_dma) * KMALLOC_RECLAIM;
+}
+
+/* { dg-final { scan-tree-dump-times { \* } 1 "optimized" } } */