fold-const.c (fold_binary_loc): Move (T)ptr & CST folding...
2015-07-03 Richard Biener <rguenther@suse.de> * fold-const.c (fold_binary_loc): Move (T)ptr & CST folding... * match.pd: ... here. From-SVN: r225368
This commit is contained in:
parent
bfdb257aa3
commit
bab73f11b8
|
@ -1,3 +1,8 @@
|
||||||
|
2015-07-03 Richard Biener <rguenther@suse.de>
|
||||||
|
|
||||||
|
* fold-const.c (fold_binary_loc): Move (T)ptr & CST folding...
|
||||||
|
* match.pd: ... here.
|
||||||
|
|
||||||
2015-07-03 Gerald Pfeifer <gerald@pfeifer.com>
|
2015-07-03 Gerald Pfeifer <gerald@pfeifer.com>
|
||||||
|
|
||||||
PR target/37072
|
PR target/37072
|
||||||
|
|
|
@ -11069,25 +11069,6 @@ fold_binary_loc (location_t loc,
|
||||||
fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0));
|
fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If arg0 is derived from the address of an object or function, we may
|
|
||||||
be able to fold this expression using the object or function's
|
|
||||||
alignment. */
|
|
||||||
if (POINTER_TYPE_P (TREE_TYPE (arg0)) && TREE_CODE (arg1) == INTEGER_CST)
|
|
||||||
{
|
|
||||||
unsigned int align;
|
|
||||||
unsigned HOST_WIDE_INT bitpos;
|
|
||||||
|
|
||||||
get_pointer_alignment_1 (arg0, &align, &bitpos);
|
|
||||||
|
|
||||||
/* This works because modulus is a power of 2. If this weren't the
|
|
||||||
case, we'd have to replace it by its greatest power-of-2
|
|
||||||
divisor: modulus & -modulus. */
|
|
||||||
if (wi::ltu_p (arg1, align / BITS_PER_UNIT))
|
|
||||||
return wide_int_to_tree (type,
|
|
||||||
wi::bit_and (arg1,
|
|
||||||
bitpos / BITS_PER_UNIT));
|
|
||||||
}
|
|
||||||
|
|
||||||
goto associate;
|
goto associate;
|
||||||
|
|
||||||
case RDIV_EXPR:
|
case RDIV_EXPR:
|
||||||
|
|
15
gcc/match.pd
15
gcc/match.pd
|
@ -668,6 +668,21 @@ along with GCC; see the file COPYING3. If not see
|
||||||
(if (ptr_difference_const (@0, @1, &diff))
|
(if (ptr_difference_const (@0, @1, &diff))
|
||||||
{ build_int_cst_type (type, diff); }))))
|
{ build_int_cst_type (type, diff); }))))
|
||||||
|
|
||||||
|
/* If arg0 is derived from the address of an object or function, we may
|
||||||
|
be able to fold this expression using the object or function's
|
||||||
|
alignment. */
|
||||||
|
(simplify
|
||||||
|
(bit_and (convert? @0) INTEGER_CST@1)
|
||||||
|
(if (POINTER_TYPE_P (TREE_TYPE (@0))
|
||||||
|
&& tree_nop_conversion_p (type, TREE_TYPE (@0)))
|
||||||
|
(with
|
||||||
|
{
|
||||||
|
unsigned int align;
|
||||||
|
unsigned HOST_WIDE_INT bitpos;
|
||||||
|
get_pointer_alignment_1 (@0, &align, &bitpos);
|
||||||
|
}
|
||||||
|
(if (wi::ltu_p (@1, align / BITS_PER_UNIT))
|
||||||
|
{ wide_int_to_tree (type, wi::bit_and (@1, bitpos / BITS_PER_UNIT)); }))))
|
||||||
|
|
||||||
|
|
||||||
/* We can't reassociate at all for saturating types. */
|
/* We can't reassociate at all for saturating types. */
|
||||||
|
|
Loading…
Reference in New Issue