Hi, Backporting of the fix went into GCC 5 seems to intrusive for the released branches. Hence I'd propose to remove the problematic patterns altogether, as they can silently generate wrong code. The attached patch does that. Tested briefly with 'make all' and with make -k check-gcc RUNTESTFLAGS="sh.exp --target_board=sh-sim \{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}"
Kaz, do you have any objections? Cheers, Oleg gcc/ChangeLog: PR target/53988 * config/sh/sh.md (*tst<mode>_t_zero): Remove insns. gcc/testsuite/ChangeLog: PR target/53988 * gcc.target/sh/pr53988.c: Mark tests as xfail.
Index: gcc/config/sh/sh.md =================================================================== --- gcc/config/sh/sh.md (revision 221258) +++ gcc/config/sh/sh.md (working copy) @@ -651,32 +651,6 @@ "tst #255,%0" [(set_attr "type" "mt_group")]) -;; This pattern might be risky because it also tests the upper bits and not -;; only the subreg. However, it seems that combine will get to this only -;; when testing sign/zero extended values. In this case the extended upper -;; bits do not matter. -(define_insn "*tst<mode>_t_zero" - [(set (reg:SI T_REG) - (eq:SI - (subreg:QIHI - (and:SI (match_operand:SI 0 "arith_reg_operand" "%r") - (match_operand:SI 1 "arith_reg_operand" "r")) <lowpart_le>) - (const_int 0)))] - "TARGET_SH1 && TARGET_LITTLE_ENDIAN" - "tst %0,%1" - [(set_attr "type" "mt_group")]) - -(define_insn "*tst<mode>_t_zero" - [(set (reg:SI T_REG) - (eq:SI - (subreg:QIHI - (and:SI (match_operand:SI 0 "arith_reg_operand" "%r") - (match_operand:SI 1 "arith_reg_operand" "r")) <lowpart_be>) - (const_int 0)))] - "TARGET_SH1 && TARGET_BIG_ENDIAN" - "tst %0,%1" - [(set_attr "type" "mt_group")]) - ;; Extract LSB, negate and store in T bit. (define_insn "tstsi_t_and_not" [(set (reg:SI T_REG) Index: gcc/testsuite/gcc.target/sh/pr53988.c =================================================================== --- gcc/testsuite/gcc.target/sh/pr53988.c (revision 221258) +++ gcc/testsuite/gcc.target/sh/pr53988.c (working copy) @@ -5,9 +5,9 @@ /* { dg-do compile } */ /* { dg-options "-O1" } */ /* { dg-skip-if "" { "sh*-*-*" } { "-m5*"} { "" } } */ -/* { dg-final { scan-assembler-times "tst\tr" 8 } } */ -/* { dg-final { scan-assembler-not "tst\t#255" } } */ -/* { dg-final { scan-assembler-not "exts|extu|and|movu" } } */ +/* { dg-final { scan-assembler-times "tst\tr" 8 { xfail *-*-*} } } */ +/* { dg-final { scan-assembler-not "tst\t#255" { xfail *-*-*} } } */ +/* { dg-final { scan-assembler-not "exts|extu|and|movu" { xfail *-*-*} } } */ int test00 (char* a, char* b, int c, int d)