From: Yury Gribov Date: Mon, 22 Oct 2018 20:26:32 +0000 (+0000) Subject: re PR tree-optimization/87633 (ice in compare_range_wit h_value, at vr-values.c:1702) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f38428472d7dfd61cc0397cc85eb45b8f7fe0348;p=gcc.git re PR tree-optimization/87633 (ice in compare_range_wit h_value, at vr-values.c:1702) 2018-10-22 Yury Gribov gcc/ PR tree-optimization/87633 * match.pd: Do not generate unordered integer comparisons. gcc/testsuite/ PR tree-optimization/87633 * g++.dg/pr87633.C: New test. From-SVN: r265399 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1cfcc31b963..472d8f7440c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-10-22 Yury Gribov + + PR tree-optimization/87633 + * match.pd: Do not generate unordered integer comparisons. + 2018-10-22 Segher Boessenkool PR rtl-optimization/87600 diff --git a/gcc/match.pd b/gcc/match.pd index b36d7ccb5dc..8796a406f82 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3401,7 +3401,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (cmp @0 @1)))))) /* Optimize various special cases of (FTYPE) N CMP (FTYPE) M. */ -(for cmp (tcc_comparison) +(for cmp (lt le eq ne ge gt unordered ordered unlt unle ungt unge uneq ltgt) + icmp (lt le eq ne ge gt unordered ordered lt le gt ge eq ne) (simplify (cmp (float@0 @1) (float @2)) (if (SCALAR_FLOAT_TYPE_P (TREE_TYPE (@0)) @@ -3416,15 +3417,17 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) } (if (fmt.can_represent_integral_type_p (type1) && fmt.can_represent_integral_type_p (type2)) - (if (TYPE_PRECISION (type1) > TYPE_PRECISION (type2) - && type1_signed_p >= type2_signed_p) - (cmp @1 (convert @2)) - (if (TYPE_PRECISION (type1) < TYPE_PRECISION (type2) - && type1_signed_p <= type2_signed_p) - (cmp (convert:type2 @1) @2) - (if (TYPE_PRECISION (type1) == TYPE_PRECISION (type2) - && type1_signed_p == type2_signed_p) - (cmp @1 @2))))))))) + (if (cmp == ORDERED_EXPR || cmp == UNORDERED_EXPR) + { constant_boolean_node (cmp == ORDERED_EXPR, type); } + (if (TYPE_PRECISION (type1) > TYPE_PRECISION (type2) + && type1_signed_p >= type2_signed_p) + (icmp @1 (convert @2)) + (if (TYPE_PRECISION (type1) < TYPE_PRECISION (type2) + && type1_signed_p <= type2_signed_p) + (icmp (convert:type2 @1) @2) + (if (TYPE_PRECISION (type1) == TYPE_PRECISION (type2) + && type1_signed_p == type2_signed_p) + (icmp @1 @2)))))))))) /* Optimize various special cases of (FTYPE) N CMP CST. */ (for cmp (lt le eq ne ge gt) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 976b4b16a8f..0a4700a3aae 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-10-22 Yury Gribov + + PR tree-optimization/87633 + * g++.dg/pr87633.C: New test. + 2018-10-22 Marek Polacek PR testsuite/87694 diff --git a/gcc/testsuite/g++.dg/pr87633.C b/gcc/testsuite/g++.dg/pr87633.C new file mode 100644 index 00000000000..86926cd8bf8 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr87633.C @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +class a { +public: + double b() const; +}; +class c { +public: + int m_fn2() const; +}; +double a::b() const { + return 0 == 0 ? reinterpret_cast(this)->m_fn2() : 0; +} +bool d; +void e() { + a f; + double g = f.b(); + /* { dg-final { scan-tree-dump-not "unord" "optimized" } } */ + d = __builtin_isnan(g); +}