summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/ieee
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2000-01-24 20:10:04 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2000-01-24 20:10:04 +0000
commita4110d9a66b1bfab2679b8b4774839bcfb1b3cba (patch)
treea9f7967b844ec94122754eade0945e4f551bf9f1 /gcc/testsuite/gcc.c-torture/execute/ieee
parent8581412d5881e717bf3351f305d6b2e99dd64f96 (diff)
downloadgcc-a4110d9a66b1bfab2679b8b4774839bcfb1b3cba.tar.gz
* rtl.def: Add unordered fp comparisions.
* tree.def: Likewise. * tree.h: Add ISO C 9x unordered fp comparision builtins. * builtins.c (expand_tree_builtin): New function. * c-typeck.c (build_function_call): Use it. (build_binary_op): Support unordered compares. * c-common.c (c_common_nodes_and_builtins): Add unordered compares. * combine.c (known_cond): Handle reverse_condition returning UNKNOWN. (reversible_comparison_p): Allow UNORDERED/ORDERED to be reversed. * cse.c (fold_rtx): Check FLOAT_MODE_P before reversing. (record_jump_equiv): Handle reverse_condition returning UNKNOWN. * jump.c (reverse_condition): Don't abort for UNLE etc, but return UNKNOWN. (swap_condition): Handle unordered compares. (thread_jumps): Check can_reverse before reversing. * loop.c (get_condition): Likewise. Allow UNORERED/ORDERED to be reversed for FP. * optabs.c (can_compare_p): New argument CODE. Verify branch or setcc is present before acking for cmp_optab. Update all callers. (prepare_float_lib_cmp, init_optabs): Handle UNORDERED. * expmed.c (do_cmp_and_jump): Update for can_compare_p. * expr.c (expand_expr): Likewise. Support unordered compares. (do_jump, do_store_flag): Likewise. * expr.h (enum libfunc_index): Add unordered compares. * Makefile.in (FPBIT_FUNCS): Add _unord_sf. (DPBIT_FUNCS): Add _unord_df. * config/fp-bit.c (_unord_f2): New. * fp-test.c (main): Try unordered compare builtins. * alpha-protos.h (alpha_fp_comparison_operator): Declare. * alpha.c (alpha_comparison_operator): Check mode properly. (alpha_swapped_comparison_operator): Likewise. (signed_comparison_operator): Likewise. (alpha_fp_comparison_operator): New. (alpha_emit_conditional_branch): Handle unordered compares. * alpha.h (PREDICATE_CODES): Update. * alpha.md (fp compares): Use alpha_fp_comparison_operator. (bunordered, bordered): New. * cp/call.c (build_over_call): Use expand_tree_builtin. * cp/typeck.c (build_function_call_real): Likewise. (build_binary_op_nodefault): Handle unordered compares. * gcc.c-torture/execute/ieee/fp-cmp-4.c: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@31591 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.c-torture/execute/ieee')
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-4.c131
1 files changed, 131 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-4.c b/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-4.c
new file mode 100644
index 00000000000..80342eefa9b
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-4.c
@@ -0,0 +1,131 @@
+void
+test_isunordered(double x, double y, int true)
+{
+ if (__builtin_isunordered(x, y))
+ {
+ if (! true)
+ abort ();
+ }
+ else
+ {
+ if (true)
+ abort ();
+ }
+}
+
+void
+test_isless(double x, double y, int true)
+{
+ if (__builtin_isless(x, y))
+ {
+ if (! true)
+ abort ();
+ }
+ else
+ {
+ if (true)
+ abort ();
+ }
+}
+
+void
+test_islessequal(double x, double y, int true)
+{
+ if (__builtin_islessequal(x, y))
+ {
+ if (! true)
+ abort ();
+ }
+ else
+ {
+ if (true)
+ abort ();
+ }
+}
+
+void
+test_isgreater(double x, double y, int true)
+{
+ if (__builtin_isgreater(x, y))
+ {
+ if (! true)
+ abort ();
+ }
+ else
+ {
+ if (true)
+ abort ();
+ }
+}
+
+void
+test_isgreaterequal(double x, double y, int true)
+{
+ if (__builtin_isgreaterequal(x, y))
+ {
+ if (! true)
+ abort ();
+ }
+ else
+ {
+ if (true)
+ abort ();
+ }
+}
+
+void
+test_islessgreater(double x, double y, int true)
+{
+ if (__builtin_islessgreater(x, y))
+ {
+ if (! true)
+ abort ();
+ }
+ else
+ {
+ if (true)
+ abort ();
+ }
+}
+
+#define NAN (0.0 / 0.0)
+
+int
+main()
+{
+ struct try
+ {
+ double x, y;
+ unsigned unord : 1;
+ unsigned lt : 1;
+ unsigned le : 1;
+ unsigned gt : 1;
+ unsigned ge : 1;
+ unsigned lg : 1;
+ };
+
+ const struct try data[] =
+ {
+ { NAN, NAN, 1, 0, 0, 0, 0, 0 },
+ { 0.0, NAN, 1, 0, 0, 0, 0, 0 },
+ { NAN, 0.0, 1, 0, 0, 0, 0, 0 },
+ { 0.0, 0.0, 0, 0, 1, 0, 1, 0 },
+ { 1.0, 2.0, 0, 1, 1, 0, 0, 1 },
+ { 2.0, 1.0, 0, 0, 0, 1, 1, 1 },
+ };
+
+ const int n = sizeof(data) / sizeof(data[0]);
+ int i;
+
+ for (i = 0; i < n; ++i)
+ {
+ test_isunordered (data[i].x, data[i].y, data[i].unord);
+ test_isless (data[i].x, data[i].y, data[i].lt);
+ test_islessequal (data[i].x, data[i].y, data[i].le);
+ test_isgreater (data[i].x, data[i].y, data[i].gt);
+ test_isgreaterequal (data[i].x, data[i].y, data[i].ge);
+ test_islessgreater (data[i].x, data[i].y, data[i].lg);
+ }
+
+ exit (0);
+}