On Wed, 2020-01-29 at 19:18 +0000, Richard Sandiford wrote: > Andreas Schwab <sch...@suse.de> writes: > > On Jan 27 2020, Richard Sandiford wrote: > > > > > * simplify-rtx.c (simplify_truncation): Extend sign/zero_extract > > > simplification to handle subregs as well as bare regs. > > > > That breaks gcc.target/m68k/pr39726.c > > Gah. Jeff pointed out off-list that it also broke > gcc.target/sh/pr64345-1.c on sh3-linux-gnu. It didn't look like either > of them would be fixable in an acceptably non-invasive and unhacky way, > so I've reverted the patch "for now". I would have considered letting those two targets regress those tests to move forward on 87763. aarch64 is (IMHO) more important than the sh and m68k combined ;-) It also seems to me that your patch generates better RTL and that we could claim that a port that regresses on code quality needs its port maintainer to step in and fix the port.
WRT the m68k issue I'd think it could be fixed by twiddling cbranchsi4_btst_reg_insn_1 to accept a mode iterator on the zero_extract and making some minor adjustments in its output code. Something like the attached. I haven't tested it in any real way and haven't really thought about whether or not it does the right thing for a MEM operand. I'd be surprised if the SH fix wasn't similar, but I know almost nothing about the SH implementation. Jeff
diff --git a/gcc/config/m68k/m68k.md b/gcc/config/m68k/m68k.md index 8e35357ea23..78c4cbe4753 100644 --- a/gcc/config/m68k/m68k.md +++ b/gcc/config/m68k/m68k.md @@ -644,12 +644,12 @@ return m68k_output_branch_integer (code); }) -(define_insn "cbranchsi4_btst_reg_insn_1" +(define_insn "cbranch<mode>4_btst_reg_insn_1" [(set (pc) (if_then_else (match_operator 0 "equality_comparison_operator" - [(zero_extract:SI (match_operand:SI 1 "nonimmediate_operand" "do,dQ") - (const_int 1) - (match_operand:SI 2 "const_int_operand" "n,n")) + [(zero_extract:I (match_operand:I 1 "nonimmediate_operand" "do,dQ") + (const_int 1) + (match_operand:I 2 "const_int_operand" "n,n")) (const_int 0)]) (label_ref (match_operand 3 "")) (pc)))] @@ -665,8 +665,9 @@ } else { - operands[2] = GEN_INT (31 - INTVAL (operands[2])); - code = m68k_output_btst (operands[2], operands[1], code, 31); + operands[2] = GEN_INT (GET_MODE_BITSIZE (GET_MODE (operands[1])) + - INTVAL (operands[2]) - 1); + code = m68k_output_btst (operands[2], operands[1], code, GET_MODE_BITSIZE (GET_MODE (operands[1])) - 1); } return m68k_output_branch_integer (code); }