summaryrefslogtreecommitdiff
path: root/gcc/match.pd
diff options
context:
space:
mode:
authorBarnaby Wilks <barnaby.wilks@arm.com>2019-09-09 12:05:36 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2019-09-09 12:05:36 +0000
commita6edd18cb32993213508aaa4879af7485c1bbaac (patch)
tree55532c779ab56965c8989e0f6e4c2c47b0fba1b3 /gcc/match.pd
parentf48ef52e40171a47221401a0f7b4e8648b6c541f (diff)
match.pd: Add flag_unsafe_math_optimizations check before deciding on the widest type in...
2019-09-09 Barnaby Wilks <barnaby.wilks@arm.com> * match.pd: Add flag_unsafe_math_optimizations check before deciding on the widest type in a binary math operation. * gcc.dg/fold-binary-math-casts.c: New test. From-SVN: r275518
Diffstat (limited to 'gcc/match.pd')
-rw-r--r--gcc/match.pd12
1 files changed, 10 insertions, 2 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index 1d13543a615..5b2d95dfa9d 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -5040,10 +5040,18 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
&& newtype == type
&& types_match (newtype, type))
(op (convert:newtype @1) (convert:newtype @2))
- (with { if (TYPE_PRECISION (ty1) > TYPE_PRECISION (newtype))
+ (with
+ {
+ if (!flag_unsafe_math_optimizations)
+ {
+ if (TYPE_PRECISION (ty1) > TYPE_PRECISION (newtype))
newtype = ty1;
+
if (TYPE_PRECISION (ty2) > TYPE_PRECISION (newtype))
- newtype = ty2; }
+ newtype = ty2;
+ }
+ }
+
/* Sometimes this transformation is safe (cannot
change results through affecting double rounding
cases) and sometimes it is not. If NEWTYPE is