+2006-10-23 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/21032
+ * convert.c (convert_to_real): Fold (float)-x to -(float)x
+ only if not flag_rounding_math.
+
2006-10-22 Richard Sandiford <richard@codesourcery.com>
Kaz Kojima <kkojima@gcc.gnu.org>
if (itype != type && FLOAT_TYPE_P (type))
switch (TREE_CODE (expr))
{
- /* Convert (float)-x into -(float)x. This is always safe. */
+ /* Convert (float)-x into -(float)x. This is safe for
+ round-to-nearest rounding mode. */
case ABS_EXPR:
case NEGATE_EXPR:
- if (TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (expr)))
+ if (!flag_rounding_math
+ && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (expr)))
return build1 (TREE_CODE (expr), type,
fold (convert_to_real (type,
TREE_OPERAND (expr, 0))));
+2006-10-23 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/21032
+ * gcc.dg/pr21032.c: New testcase.
+
2006-10-22 Jeff Law <law@redhat.com>
Richard Guenther <rguenther@suse.de>
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized -frounding-math" } */
+
+void bar(float x);
+void foo(double x)
+{
+ bar(-x);
+}
+
+/* { dg-final { scan-tree-dump-not "-\\(float\\)" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */