The patch fixes the s390x crash reported in PR 79240: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79240 Regression tested and bootstrapped on s390x biarch and s390.
Ciao Dominik ^_^ ^_^ -- Dominik Vogt IBM Germany
gcc/ChangeLog-pr79240 PR target/79240 * config/s390/s390.c (s390_extzv_shift_ok): Returns false, don't assert. * config/s390/s390.md ("*r<noxa>sbg_<mode>_srl_bitmask") ("*r<noxa>sbg_<mode>_sll_bitmask") ("*extzv_<mode>_srl<clobbercc_or_nocc>") ("*extzv_<mode>_sll<clobbercc_or_nocc>"): Use contiguous_bitmask_nowrap_operand gcc/testsuite/ChangeLog-pr79240 * gcc.target/s390/pr79240.c: New test.
>From 0c9bc9c84a98c90df54c58dbdc299e064b3a9c5f Mon Sep 17 00:00:00 2001 From: Dominik Vogt <v...@linux.vnet.ibm.com> Date: Thu, 26 Jan 2017 13:50:46 +0100 Subject: [PATCH] S/390: PR target/79240: Fix assertion in s390_extzv_shift_ok. --- gcc/config/s390/s390.c | 3 ++- gcc/config/s390/s390.md | 8 ++++---- gcc/testsuite/gcc.target/s390/pr79240.c | 12 ++++++++++++ 3 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.target/s390/pr79240.c diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index fe65846..b1dfbfa 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -2472,7 +2472,8 @@ s390_extzv_shift_ok (int bitsize, int rotl, unsigned HOST_WIDE_INT contig) bool ok; ok = s390_contiguous_bitmask_nowrap_p (contig, bitsize, &start, &end); - gcc_assert (ok); + if (!ok) + return false; if (rotl >= 0) return (64 - end >= rotl); diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index 3135175..e47c2e9 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -4127,7 +4127,7 @@ (lshiftrt:GPR (match_operand:GPR 1 "nonimmediate_operand" "d") (match_operand:GPR 3 "nonzero_shift_count_operand" "")) - (match_operand:GPR 2 "contiguous_bitmask_operand" "")) + (match_operand:GPR 2 "contiguous_bitmask_nowrap_operand" "")) (match_operand:GPR 4 "nonimmediate_operand" "0"))) (clobber (reg:CC CC_REGNUM))] "TARGET_Z10 @@ -4143,7 +4143,7 @@ (ashift:GPR (match_operand:GPR 1 "nonimmediate_operand" "d") (match_operand:GPR 3 "nonzero_shift_count_operand" "")) - (match_operand:GPR 2 "contiguous_bitmask_operand" "")) + (match_operand:GPR 2 "contiguous_bitmask_nowrap_operand" "")) (match_operand:GPR 4 "nonimmediate_operand" "0"))) (clobber (reg:CC CC_REGNUM))] "TARGET_Z10 @@ -7191,7 +7191,7 @@ (and:GPR (lshiftrt:GPR (match_operand:GPR 1 "register_operand" "d") (match_operand:GPR 2 "nonzero_shift_count_operand" "")) - (match_operand:GPR 3 "contiguous_bitmask_operand" "")))] + (match_operand:GPR 3 "contiguous_bitmask_nowrap_operand" "")))] "<z10_or_zEC12_cond> /* Note that even for the SImode pattern, the rotate is always DImode. */ && s390_extzv_shift_ok (<bitsize>, -INTVAL (operands[2]), @@ -7205,7 +7205,7 @@ (and:GPR (ashift:GPR (match_operand:GPR 1 "register_operand" "d") (match_operand:GPR 2 "nonzero_shift_count_operand" "")) - (match_operand:GPR 3 "contiguous_bitmask_operand" "")))] + (match_operand:GPR 3 "contiguous_bitmask_nowrap_operand" "")))] "<z10_or_zEC12_cond> && s390_extzv_shift_ok (<bitsize>, INTVAL (operands[2]), INTVAL (operands[3]))" diff --git a/gcc/testsuite/gcc.target/s390/pr79240.c b/gcc/testsuite/gcc.target/s390/pr79240.c new file mode 100644 index 0000000..10d3be8 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/pr79240.c @@ -0,0 +1,12 @@ +/* This testcase checks that s390_extzv_shift_ok does not cause an assertion + failure. */ + +/* { dg-do compile } */ +/* { dg-options "-w -march=z196 -mtune=zEC12 -m64 -mzarch -O2" } */ + +a, b; +c () +{ + int d = sizeof (int) * a + 16 - a * sizeof (int) % 16; + b = d; +} -- 2.3.0