From b8d850056860ea8cdc47234d3fbf89c8d03c9342 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 15 Jun 2018 21:30:58 +0200 Subject: [PATCH] re PR middle-end/86123 (ICE in prepare_cmp_insn, at optabs.c:3967) PR middle-end/86123 * match.pd ((X / Y) == 0 -> X < Y): Don't transform complex divisions. Fix up comment formatting. * gcc.c-torture/compile/pr86123.c: New test. From-SVN: r261647 --- gcc/ChangeLog | 6 ++++++ gcc/match.pd | 7 ++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/compile/pr86123.c | 17 +++++++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr86123.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c91c81effcc..9c7c574c762 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-06-15 Jakub Jelinek + + PR middle-end/86123 + * match.pd ((X / Y) == 0 -> X < Y): Don't transform complex divisions. + Fix up comment formatting. + 2018-06-15 Bernd Edlinger * typed-splay-tree.h (typed_splay_tree::remove): New function. diff --git a/gcc/match.pd b/gcc/match.pd index f70a88c362e..7e22771ec7c 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1462,14 +1462,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (op @1 { build_zero_cst (TREE_TYPE (@1)); })))) /* Transform: - * (X / Y) == 0 -> X < Y if X, Y are unsigned. - * (X / Y) != 0 -> X >= Y, if X, Y are unsigned. - */ + (X / Y) == 0 -> X < Y if X, Y are unsigned. + (X / Y) != 0 -> X >= Y, if X, Y are unsigned. */ (for cmp (eq ne) ocmp (lt ge) (simplify (cmp (trunc_div @0 @1) integer_zerop) (if (TYPE_UNSIGNED (TREE_TYPE (@0)) + /* Complex ==/!= is allowed, but not =. */ + && TREE_CODE (TREE_TYPE (@0)) != COMPLEX_TYPE && (VECTOR_TYPE_P (type) || !VECTOR_TYPE_P (TREE_TYPE (@0)))) (ocmp @0 @1)))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 72b8615a612..045c4cd6849 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-06-15 Jakub Jelinek + + PR middle-end/86123 + * gcc.c-torture/compile/pr86123.c: New test. + 2018-06-15 Tom de Vries * gcc.dg-selftests/dg-final.exp: Force sequential execution. diff --git a/gcc/testsuite/gcc.c-torture/compile/pr86123.c b/gcc/testsuite/gcc.c-torture/compile/pr86123.c new file mode 100644 index 00000000000..707e6dc0adb --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr86123.c @@ -0,0 +1,17 @@ +/* PR middle-end/86123 */ + +int +foo (_Complex unsigned x, _Complex unsigned y) +{ + _Complex unsigned t1 = x / y; + int t2 = (t1 != 0); + return t2; +} + +int +bar (_Complex unsigned x, _Complex unsigned y) +{ + _Complex unsigned t1 = x / y; + int t2 = (t1 == 0); + return t2; +} -- 2.30.2