[Committed] Delete tree_fold_gcd
Roger Sayle
roger@eyesopen.com
Sun Jan 28 05:05:00 GMT 2007
As I first commented a long while back, the only use of the function
tree_fold_gcd in the tree is in tree-data-ref.c's tree_fold_divides_p to
test whether one integer constant is a multiple of another.
http://gcc.gnu.org/ml/gcc-patches/2005-12/msg01699.html
It turns out that using Greatest-Common-Divisor to test this via the
comparison "gcd(a,b) == a" is a particularly inefficient implementation.
Instead the patch below follows the idiom used in fold-const.c's
multiple_of_p routine which is to call int_const_binop with the tree code
TRUNC_MOD_EXPR and test whether the return value is zero. It would be nice
not to create the tree node for the result, but this already significantly
better then the current implementation which creates numerous tree nodes.
The following patch has been tested on x86_64-unknown-linux-gnu with a
full "make bootstrap", all default languages, and regression tested with a
top-level "make -k check" with no new failures.
Committed to mainline as revision 121253.
2007-01-27 Roger Sayle <roger@eyesopen.com>
* tree.c (tree_fold_gcd): Delete.
* tree.h (tree_fold_gcd): Remove prototype.
* tree-data-ref.c (tree_fold_divides_p): Don't use tree_fold_gcd to
test whether one constant integer is a multiple of another. Instead
call int_const_binop with TRUNC_MOD_EXPR and test for a zero result.
* fold-const.c (multiple_of_p): We've determined both TOP and
BOTTOM are integer constants so we can call int_const_binop directly
instead of the more generic const_binop.
Roger
--
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patchg.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070128/6d95364c/attachment.txt>
More information about the Gcc-patches
mailing list