From 48fcd201c4490f7c2b99f3d76b7bf7070b22733e Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 14 Jun 2018 21:07:45 +0200 Subject: [PATCH] re PR middle-end/86122 (ICE in useless_type_conversion_p, at gimple-expr.c:87) PR middle-end/86122 * match.pd ((A +- CST1) +- CST2): Punt if last resort unsigned_type_for returns NULL. * gcc.c-torture/compile/pr86122.c: New test. From-SVN: r261606 --- gcc/ChangeLog | 4 ++++ gcc/match.pd | 9 +++++---- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gcc.c-torture/compile/pr86122.c | 17 +++++++++++++++++ 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr86122.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 65284fb6fbc..8e360fb0e8d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2018-06-14 Jakub Jelinek + PR middle-end/86122 + * match.pd ((A +- CST1) +- CST2): Punt if last resort + unsigned_type_for returns NULL. + PR target/85945 * lower-subreg.c (find_decomposable_subregs): Don't decompose float subregs of multi-word pseudos unless the float mode has word size. diff --git a/gcc/match.pd b/gcc/match.pd index 14386da070b..f70a88c362e 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1771,10 +1771,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (neg_inner_op @0 { wide_int_to_tree (type, wi::to_wide (cst)); }) /* Last resort, use some unsigned type. */ (with { tree utype = unsigned_type_for (type); } - (view_convert (inner_op - (view_convert:utype @0) - (view_convert:utype - { drop_tree_overflow (cst); }))))))))))))) + (if (utype) + (view_convert (inner_op + (view_convert:utype @0) + (view_convert:utype + { drop_tree_overflow (cst); })))))))))))))) /* (CST1 - A) +- CST2 -> CST3 - A */ (for outer_op (plus minus) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 92bc519e558..9c15279f09b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2018-06-14 Jakub Jelinek + PR middle-end/86122 + * gcc.c-torture/compile/pr86122.c: New test. + P0624R2 - Default constructible and assignable stateless lambdas * g++.dg/cpp2a/lambda1.C: New test. * g++.dg/cpp0x/lambda/lambda-ice2.C: Adjust expected diagnostics diff --git a/gcc/testsuite/gcc.c-torture/compile/pr86122.c b/gcc/testsuite/gcc.c-torture/compile/pr86122.c new file mode 100644 index 00000000000..0a4fd144ae6 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr86122.c @@ -0,0 +1,17 @@ +/* PR middle-end/86122 */ + +_Complex int +foo (_Complex int x) +{ + x += __INT_MAX__; + x += 1; + return x; +} + +_Complex int +bar (_Complex int x) +{ + x += 1; + x += __INT_MAX__; + return x; +} -- 2.30.2