From ad7ab32ed443d716f45ed315aa5349981954aa6c Mon Sep 17 00:00:00 2001 From: Dominik Vogt Date: Mon, 19 Dec 2016 09:53:56 +0000 Subject: [PATCH] PR target/78748: S/390: Fix ICE with ANDC splitter. gcc/ChangeLog: 2016-12-19 Dominik Vogt PR target/78748 * config/s390/s390.md ("*andc_split_"): Allow memory destination only if it coincides with operand 2. gcc/testsuite/ChangeLog: 2016-12-19 Dominik Vogt PR target/78748 * gcc.c-torture/compile/pr78748.c: New test. From-SVN: r243793 --- gcc/ChangeLog | 6 ++++++ gcc/config/s390/s390.md | 6 +++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/compile/pr78748.c | 14 ++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr78748.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3622483545c..8255e501d91 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-12-19 Dominik Vogt + + PR target/78748 + * config/s390/s390.md ("*andc_split_"): Allow memory destination + only if it coincides with operand 2. + 2016-12-19 Dominik Vogt * combine.c (change_zero_ext): Skip generation of redundant AND. diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index 4f2effd93ff..9d8e6b61a42 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -7420,7 +7420,11 @@ (and:GPR (not:GPR (match_operand:GPR 1 "nonimmediate_operand" "")) (match_operand:GPR 2 "general_operand" ""))) (clobber (reg:CC CC_REGNUM))] - "! reload_completed && s390_logical_operator_ok_p (operands)" + "! reload_completed + && (GET_CODE (operands[0]) != MEM + /* Ensure that s390_logical_operator_ok_p will succeed even + on the split xor if (b & a) is stored into a pseudo. */ + || rtx_equal_p (operands[0], operands[2]))" "#" "&& 1" [ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7b91b7b86b0..53813b5ab24 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-12-19 Dominik Vogt + + PR target/78748 + * gcc.c-torture/compile/pr78748.c: New test. + 2016-12-18 Janus Weil PR fortran/78848 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr78748.c b/gcc/testsuite/gcc.c-torture/compile/pr78748.c new file mode 100644 index 00000000000..032e78db7c2 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr78748.c @@ -0,0 +1,14 @@ +/* PR target/78748 */ +/* { dg-options "-march=zEC12" { target { s390*-*-* } } } */ + +void +foo (int *p, int *q) +{ + *q = *p & ~*q; +} + +void +bar (int *p, int *q) +{ + *q = ~*p & *q; +} -- 2.30.2