match.pd (X - (X / Y) * Y): Use convert1 and convert2.
* match.pd (X - (X / Y) * Y): Use convert1 and convert2. Convert both operands of the resulting expression. * gcc.dg/fold-minus-6.c: New test. From-SVN: r225195
This commit is contained in:
parent
b451c27117
commit
d3bc1d1b65
4 changed files with 53 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
|||
2015-06-30 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
* match.pd (X - (X / Y) * Y): Use convert1 and convert2. Convert
|
||||
both operands of the resulting expression.
|
||||
|
||||
2015-06-30 Richard Biener <rguenther@suse.de>
|
||||
|
||||
* fold-const.c (fold_binary_loc): Move ~x & ~y -> ~(x | y) and
|
||||
|
|
|
@ -240,9 +240,9 @@ along with GCC; see the file COPYING3. If not see
|
|||
|
||||
/* X - (X / Y) * Y is the same as X % Y. */
|
||||
(simplify
|
||||
(minus (convert? @0) (convert? (mult (trunc_div @0 @1) @1)))
|
||||
(minus (convert1? @0) (convert2? (mult (trunc_div @0 @1) @1)))
|
||||
(if (INTEGRAL_TYPE_P (type) || VECTOR_INTEGER_TYPE_P (type))
|
||||
(convert (trunc_mod @0 @1))))
|
||||
(trunc_mod (convert @0) (convert @1))))
|
||||
|
||||
/* Optimize TRUNC_MOD_EXPR by a power of two into a BIT_AND_EXPR,
|
||||
i.e. "X % C" into "X & (C - 1)", if X and C are positive.
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2015-06-30 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
* gcc.dg/fold-minus-6.c: New test.
|
||||
|
||||
2015-06-30 Edward Smith-Rowland <3dw4rd@verizon.net>
|
||||
|
||||
Implement N4197 - Adding u8 character literals
|
||||
|
|
42
gcc/testsuite/gcc.dg/fold-minus-6.c
Normal file
42
gcc/testsuite/gcc.dg/fold-minus-6.c
Normal file
|
@ -0,0 +1,42 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-O -fdump-tree-cddce1" } */
|
||||
|
||||
int
|
||||
fn1 (int x)
|
||||
{
|
||||
return 42L - (42 / x) * x;
|
||||
}
|
||||
|
||||
long
|
||||
fn2 (int x)
|
||||
{
|
||||
return 42L - (42 / x) * x;
|
||||
}
|
||||
|
||||
int
|
||||
fn3 (long int x)
|
||||
{
|
||||
return 42L - (42 / x) * x;
|
||||
}
|
||||
|
||||
int
|
||||
fn4 (int a, int b)
|
||||
{
|
||||
return a - (unsigned) ((a / b) * b);
|
||||
}
|
||||
|
||||
int
|
||||
fn5 (int a, unsigned int b)
|
||||
{
|
||||
return a - ((a / b) * b);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
fn6 (int a, int b)
|
||||
{
|
||||
return a - ((a / b) * b);
|
||||
}
|
||||
|
||||
/* { dg-final { scan-tree-dump-not " / " "cddce1" } } */
|
||||
/* { dg-final { scan-tree-dump-not " - " "cddce1" } } */
|
||||
/* { dg-final { scan-tree-dump-not " \\+ " "cddce1" } } */
|
Loading…
Add table
Reference in a new issue