Commit 89b80c42 by Prathamesh Kulkarni Committed by Prathamesh Kulkarni

re PR tree-optimization/71636 (Missed optimization in variable alignment test)

2016-10-17  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

	PR tree-optimization/71636
	* match.pd (x & ((1 << b) - 1) -> x & ~(~0 << b)): New pattern.

testsuite/
	* gcc.dg/pr71636-1.c: New test-case.
	* gcc.dg/pr71636-2.c: Likewise.

From-SVN: r241229
parent d6b1fea2
2016-10-17 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR tree-optimization/71636
* match.pd (x & ((1 << b) - 1) -> x & ~(~0 << b)): New pattern.
2016-10-17 Richard Biener <rguenther@suse.de>
* gimplify.c (gimplify_function_tree): Do not move the outer
......
......@@ -513,6 +513,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(bit_and:c (convert? @0) (convert? (bit_not @0)))
{ build_zero_cst (type); })
/* PR71636: Transform x & ((1U << b) - 1) -> x & ~(~0U << b); */
(simplify
(bit_and:c @0 (plus:s (lshift:s integer_onep @1) integer_minus_onep))
(if (TYPE_UNSIGNED (type))
(bit_and @0 (bit_not (lshift { build_all_ones_cst (type); } @1)))))
/* Fold (A & ~B) - (A & B) into (A ^ B) - B. */
(simplify
(minus (bit_and:cs @0 (bit_not @1)) (bit_and:cs @0 @1))
......
2016-10-17 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
* gcc.dg/pr71636-1.c: New test-case.
* gcc.dg/pr71636-2.c: Likewise.
2016-10-16 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/trampoline3.adb: New test.
......
/* { dg-do compile } */
/* { dg-options "-fdump-tree-gimple" } */
unsigned f(unsigned x, unsigned b)
{
return x & ((1U << b) - 1);
}
/* { dg-final { scan-tree-dump-not "1 <<" "gimple" } } */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-forwprop-details" } */
unsigned f(unsigned x, unsigned b)
{
unsigned t1 = 1U << b;
unsigned t2 = t1 - 1;
unsigned t3 = x & t2;
return t3;
}
/* { dg-final { scan-tree-dump "_\[0-9\] = ~_\[0-9\]" "forwprop1" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment