diff options
author | uros <uros@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-11-21 07:49:47 +0000 |
---|---|---|
committer | uros <uros@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-11-21 07:49:47 +0000 |
commit | 73444c651ff4e30a66b18ae14f5a669994238076 (patch) | |
tree | 1d2eeb3b6160ee6b9edecc9b94a1b55db1c94ced /gcc/fold-const.c | |
parent | 5b75b0ba2eae5a416236e3ce672cb716ad442cfa (diff) | |
download | gcc-73444c651ff4e30a66b18ae14f5a669994238076.tar.gz |
* fold-const.c (fold_binary) <RDIV_EXPR>: Optimize A / A to 1.0
if we don't care about NaNs or Infinities.
testsuite:
* gcc.dg/fold-div-2.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@107282 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index c4dd4f955a7..e7f550b2038 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -8227,6 +8227,17 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && real_zerop (arg1)) return NULL_TREE; + /* Optimize A / A to 1.0 if we don't care about + NaNs or Infinities. */ + if (! HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0))) + && ! HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (arg0))) + && operand_equal_p (arg0, arg1, 0)) + { + tree r = build_real (TREE_TYPE (arg0), dconst1); + + return omit_two_operands (type, r, arg0, arg1); + } + /* (-A) / (-B) -> A / B */ if (TREE_CODE (arg0) == NEGATE_EXPR && negate_expr_p (arg1)) return fold_build2 (RDIV_EXPR, type, |