+2008-01-22 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/34739
+ Backport from mainline
+ 2008-01-16 Richard Guenther <rguenther@suse.de>
+
+ PR c/34768
+ * c-typeck.c (common_pointer_type): Do not merge inconsistent
+ type qualifiers for function types.
+
+ 2007-11-12 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/34070
+ * fold-const.c (fold_binary): If testing for non-negative
+ operands with tree_expr_nonnegative_warnv_p make sure to
+ use op0 which has all (sign) conversions retained.
+
+ 2006-10-24 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/28796
+ * builtins.c (fold_builtin_classify): Use HONOR_INFINITIES
+ and HONOR_NANS instead of MODE_HAS_INFINITIES and MODE_HAS_NANS
+ for deciding optimizations in consistency with fold-const.c
+ (fold_builtin_unordered_cmp): Likewise.
+
2008-01-17 Eric Botcazou <ebotcazou@adacore.com>
Backport from mainline:
switch (builtin_index)
{
case BUILT_IN_ISINF:
- if (!MODE_HAS_INFINITIES (TYPE_MODE (TREE_TYPE (arg))))
+ if (!HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (arg))))
return omit_one_operand (type, integer_zero_node, arg);
if (TREE_CODE (arg) == REAL_CST)
return NULL_TREE;
case BUILT_IN_FINITE:
- if (!MODE_HAS_NANS (TYPE_MODE (TREE_TYPE (arg)))
- && !MODE_HAS_INFINITIES (TYPE_MODE (TREE_TYPE (arg))))
+ if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg)))
+ && !HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (arg))))
return omit_one_operand (type, integer_zero_node, arg);
if (TREE_CODE (arg) == REAL_CST)
return NULL_TREE;
case BUILT_IN_ISNAN:
- if (!MODE_HAS_NANS (TYPE_MODE (TREE_TYPE (arg))))
+ if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg))))
return omit_one_operand (type, integer_zero_node, arg);
if (TREE_CODE (arg) == REAL_CST)
if (unordered_code == UNORDERED_EXPR)
{
- if (!MODE_HAS_NANS (TYPE_MODE (TREE_TYPE (arg0))))
+ if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0))))
return omit_two_operands (type, integer_zero_node, arg0, arg1);
return fold_build2 (UNORDERED_EXPR, type, arg0, arg1);
}
- code = MODE_HAS_NANS (TYPE_MODE (TREE_TYPE (arg0))) ? unordered_code
- : ordered_code;
+ code = HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0))) ? unordered_code
+ : ordered_code;
return fold_build1 (TRUTH_NOT_EXPR, type,
fold_build2 (code, type, arg0, arg1));
}
tree pointed_to_1, mv1;
tree pointed_to_2, mv2;
tree target;
+ unsigned target_quals;
/* Save time if the two types are the same. */
if (TREE_CODE (mv2) != ARRAY_TYPE)
mv2 = TYPE_MAIN_VARIANT (pointed_to_2);
target = composite_type (mv1, mv2);
- t1 = build_pointer_type (c_build_qualified_type
- (target,
- TYPE_QUALS (pointed_to_1) |
- TYPE_QUALS (pointed_to_2)));
+
+ /* For function types do not merge const qualifiers, but drop them
+ if used inconsistently. The middle-end uses these to mark const
+ and noreturn functions. */
+ if (TREE_CODE (pointed_to_1) == FUNCTION_TYPE)
+ target_quals = TYPE_QUALS (pointed_to_1) & TYPE_QUALS (pointed_to_2);
+ else
+ target_quals = TYPE_QUALS (pointed_to_1) | TYPE_QUALS (pointed_to_2);
+ t1 = build_pointer_type (c_build_qualified_type (target, target_quals));
return build_type_attribute_variant (t1, attributes);
}
strict_overflow_p = false;
if (TREE_CODE (arg1) == LSHIFT_EXPR
&& (TYPE_UNSIGNED (type)
- || tree_expr_nonnegative_warnv_p (arg0, &strict_overflow_p)))
+ || tree_expr_nonnegative_warnv_p (op0, &strict_overflow_p)))
{
tree sval = TREE_OPERAND (arg1, 0);
if (integer_pow2p (sval) && tree_int_cst_sgn (sval) > 0)
strict_overflow_p = false;
if ((code == TRUNC_MOD_EXPR || code == FLOOR_MOD_EXPR)
&& (TYPE_UNSIGNED (type)
- || tree_expr_nonnegative_warnv_p (arg0, &strict_overflow_p)))
+ || tree_expr_nonnegative_warnv_p (op0, &strict_overflow_p)))
{
tree c = arg1;
/* Also optimize A % (C << N) where C is a power of 2,
+2008-01-22 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/34739
+ Backport from mainline
+ 2008-01-16 Richard Guenther <rguenther@suse.de>
+
+ PR c/34768
+ * gcc.c-torture/execute/pr34768-1.c: New testcase.
+ * gcc.c-torture/execute/pr34768-2.c: Likewise.
+
+ 2007-11-12 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/34070
+ * gcc.c-torture/execute/pr34070-1.c: New testcase.
+ * gcc.c-torture/execute/pr34070-2.c: Likewise.
+
+ 2006-10-24 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/28796
+ * gcc.dg/pr28796-1.c: New testcase.
+ * gcc.dg/pr28796-2.c: Likewise.
+
2008-01-19 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
* g++.dg/eh/ia64-2.C: Place "dg-do run" statement before
--- /dev/null
+extern void abort (void);
+
+int f(unsigned int x)
+{
+ return ((int)x) % 4;
+}
+
+int main()
+{
+ if (f(-1) != -1)
+ abort ();
+ return 0;
+}
--- /dev/null
+extern void abort (void);
+
+int f(unsigned int x, int n)
+{
+ return ((int)x) / (1 << n);
+}
+
+int main()
+{
+ if (f(-1, 1) != 0)
+ abort ();
+ return 0;
+}
--- /dev/null
+int x;
+
+void __attribute__((noinline)) foo (void)
+{
+ x = -x;
+}
+void __attribute__((const,noinline)) bar (void)
+{
+}
+
+int __attribute__((noinline))
+test (int c)
+{
+ int tmp = x;
+ (c ? foo : bar) ();
+ return tmp + x;
+}
+
+extern void abort (void);
+int main()
+{
+ x = 1;
+ if (test (1) != 0)
+ abort ();
+ return 0;
+}
--- /dev/null
+int x;
+
+int __attribute__((noinline)) foo (void)
+{
+ x = -x;
+ return 0;
+}
+int __attribute__((const,noinline)) bar (void)
+{
+ return 0;
+}
+
+int __attribute__((noinline))
+test (int c)
+{
+ int tmp = x;
+ int res = (c ? foo : bar) ();
+ return tmp + x + res;
+}
+
+extern void abort (void);
+int main()
+{
+ x = 1;
+ if (test (1) != 0)
+ abort ();
+ return 0;
+}
--- /dev/null
+/* { dg-do link } */
+/* { dg-options "-ffinite-math-only" } */
+
+float f;
+
+int main()
+{
+ if (__builtin_isunordered (f, f) != 0)
+ link_error ();
+ if (__builtin_isnan (f) != 0)
+ link_error ();
+ if (__builtin_finite (f) != 1)
+ link_error ();
+ if (f != f)
+ link_error ();
+ return 0;
+}
--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-O2 -funsafe-math-optimizations" } */
+
+extern void abort (void);
+
+void foo(float f)
+{
+ if (__builtin_isunordered (f, f) != 1)
+ abort ();
+ if (__builtin_isnan (f) != 1)
+ abort ();
+ if (__builtin_finite (f) != 0)
+ abort ();
+}
+
+int main()
+{
+ float f = __builtin_nanf("");
+ foo(f);
+ return 0;
+}