This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/15822] [3.5 Regression] Several alpha testsuite regressions: gcc.c-torture/execute/ieee/fp-cmp-[458].c
- From: "bonzini at gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Jun 2004 21:41:15 -0000
- Subject: [Bug target/15822] [3.5 Regression] Several alpha testsuite regressions: gcc.c-torture/execute/ieee/fp-cmp-[458].c
- References: <20040604155944.15822.ro@techfak.uni-bielefeld.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From bonzini at gnu dot org 2004-06-08 21:41 -------
This fails at -O0 as well:
int main() {
return __builtin_isunordered (1.0,4.0);
}
so this really egregious bug predates my patch: basically, __builtin_is*
functions are broken whenever their arguments are both constants, because we do
not fold them and the alpha expander breaks. This is quite serious; I do not
know to what extent it applies for 3.4.1, but the patch below seems quite safe.
I will test it tomorrow on i686-pc-linux-gnu, I would appreciate full testing
on alpha as well.
--- gcc-save/gcc/fold-const.c 2004-05-28 20:30:47.000000000 +0200
+++ gcc/gcc/fold-const.c 2004-06-08 20:00:36.000000000 +0200
@@ -7365,6 +7572,14 @@
case GT_EXPR:
case LE_EXPR:
case GE_EXPR:
+ case UNLE_EXPR:
+ case UNLT_EXPR:
+ case UNGE_EXPR:
+ case UNGT_EXPR:
+ case UNEQ_EXPR:
+ case LTGT_EXPR:
+ case UNORDERED_EXPR:
+ case ORDERED_EXPR:
/* If one arg is a real or integer constant, put it last. */
if (tree_swap_operands_p (arg0, arg1, true))
return fold (build2 (swap_tree_comparison (code), type, arg1, arg0));
@@ -9964,8 +10361,22 @@
tree tem;
int invert;
- /* From here on, the only cases we handle are when the result is
- known to be a constant.
+ /* Two real constants can be compared explicitly from the tree
+ code. */
+ if (TREE_CODE (op0) == REAL_CST && TREE_CODE (op1) == REAL_CST)
+ {
+ REAL_VALUE_TYPE cst0 = TREE_REAL_CST (arg0);
+ REAL_VALUE_TYPE cst1 = TREE_REAL_CST (arg0);
+ int result = real_compare (code, &cst0, &cst1);
+ tem = result ? integer_one_node : integer_zero_node;
+ if (TREE_CODE (type) == BOOLEAN_TYPE)
+ return lang_hooks.truthvalue_conversion (tem);
+ else
+ return tem;
+ }
+
+ /* The only cases we handle here are when the result is known to be a
+ constant.
To compute GT, swap the arguments and do LT.
To compute GE, do LT and invert the result.
@@ -9980,9 +10391,6 @@
code = swap_tree_comparison (code);
}
- /* Note that it is safe to invert for real values here because we
- will check below in the one case that it matters. */
-
tem = NULL_TREE;
invert = 0;
if (code == NE_EXPR || code == GE_EXPR)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15822