aboutsummaryrefslogtreecommitdiff
path: root/gcc/match.pd
diff options
context:
space:
mode:
authorJiufu Guo <guojiufu@linux.ibm.com>2023-09-15 13:39:27 +0800
committerguojiufu <guojiufu@linux.ibm.com>2023-09-21 13:18:01 +0800
commitd946fc1c71bdc21e3bb23721cc4d770e48bed2e2 (patch)
tree36039925853d2d7da51556204bb39d1b5421dd63 /gcc/match.pd
parent47065ff360292c683670efb96df4b61f57dc1d9a (diff)
downloadgcc-d946fc1c71bdc21e3bb23721cc4d770e48bed2e2.zip
gcc-d946fc1c71bdc21e3bb23721cc4d770e48bed2e2.tar.gz
gcc-d946fc1c71bdc21e3bb23721cc4d770e48bed2e2.tar.bz2
using overflow_free_p to simplify pattern
In r14-3582, an "overflow_free_p" interface is added. The pattern of "(t * 2) / 2" in match.pd can be simplified by using this interface. gcc/ChangeLog: * match.pd ((t * 2) / 2): Update to use overflow_free_p.
Diffstat (limited to 'gcc/match.pd')
-rw-r--r--gcc/match.pd36
1 files changed, 6 insertions, 30 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index a37af05..ce24957 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -926,36 +926,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(if (TYPE_OVERFLOW_UNDEFINED (type))
@0
#if GIMPLE
- (with
- {
- bool overflowed = true;
- value_range vr0, vr1;
- if (INTEGRAL_TYPE_P (type)
- && get_range_query (cfun)->range_of_expr (vr0, @0)
- && get_range_query (cfun)->range_of_expr (vr1, @1)
- && !vr0.varying_p () && !vr0.undefined_p ()
- && !vr1.varying_p () && !vr1.undefined_p ())
- {
- wide_int wmin0 = vr0.lower_bound ();
- wide_int wmax0 = vr0.upper_bound ();
- wide_int wmin1 = vr1.lower_bound ();
- wide_int wmax1 = vr1.upper_bound ();
- /* If the multiplication can't overflow/wrap around, then
- it can be optimized too. */
- wi::overflow_type min_ovf, max_ovf;
- wi::mul (wmin0, wmin1, TYPE_SIGN (type), &min_ovf);
- wi::mul (wmax0, wmax1, TYPE_SIGN (type), &max_ovf);
- if (min_ovf == wi::OVF_NONE && max_ovf == wi::OVF_NONE)
- {
- wi::mul (wmin0, wmax1, TYPE_SIGN (type), &min_ovf);
- wi::mul (wmax0, wmin1, TYPE_SIGN (type), &max_ovf);
- if (min_ovf == wi::OVF_NONE && max_ovf == wi::OVF_NONE)
- overflowed = false;
- }
- }
- }
- (if (!overflowed)
- @0))
+ (with {value_range vr0, vr1;}
+ (if (INTEGRAL_TYPE_P (type)
+ && get_range_query (cfun)->range_of_expr (vr0, @0)
+ && get_range_query (cfun)->range_of_expr (vr1, @1)
+ && range_op_handler (MULT_EXPR).overflow_free_p (vr0, vr1))
+ @0))
#endif
))))