REGNO can only be called on REGs, not SUBREGs; and INTVAL does not work on REGs.
2017-02-21 Segher Boessenkool <seg...@kernel.crashing.org> * config/microblaze/microblaze.c (microblaze_expand_shift): Do not test for register moves to themselves. * config/microblaze/microblaze.md (*ashlsi3_byone, *ashrsi3_byone, *lshrsi3_byone): Test for const1_rtx instead of calling INTVAL on something that isn't necessarily a CONST_INT. --- gcc/config/microblaze/microblaze.c | 5 ++--- gcc/config/microblaze/microblaze.md | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c index 746bef1..4850e85 100644 --- a/gcc/config/microblaze/microblaze.c +++ b/gcc/config/microblaze/microblaze.c @@ -3322,11 +3322,10 @@ microblaze_expand_shift (rtx operands[]) || (GET_CODE (operands[1]) == REG) || (GET_CODE (operands[1]) == SUBREG)); - /* Shift by zero -- copy regs if necessary. */ + /* Shift by zero -- copy regs. */ if ((GET_CODE (operands[2]) == CONST_INT) && (INTVAL (operands[2]) == 0)) { - if (REGNO (operands[0]) != REGNO (operands[1])) - emit_insn (gen_movsi (operands[0], operands[1])); + emit_insn (gen_movsi (operands[0], operands[1])); return 1; } diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md index 66ebc1e..9cf83f5 100644 --- a/gcc/config/microblaze/microblaze.md +++ b/gcc/config/microblaze/microblaze.md @@ -1321,7 +1321,7 @@ (define_insn "*ashlsi3_byone" [(set (match_operand:SI 0 "register_operand" "=d") (ashift:SI (match_operand:SI 1 "register_operand" "d") (match_operand:SI 2 "arith_operand" "I")))] - "(INTVAL (operands[2]) == 1)" + "operands[2] == const1_rtx" "addk\t%0,%1,%1" [(set_attr "type" "arith") (set_attr "mode" "SI") @@ -1482,7 +1482,7 @@ (define_insn "*ashrsi3_byone" [(set (match_operand:SI 0 "register_operand" "=d") (ashiftrt:SI (match_operand:SI 1 "register_operand" "d") (match_operand:SI 2 "arith_operand" "I")))] - "(INTVAL (operands[2]) == 1)" + "operands[2] == const1_rtx" "sra\t%0,%1" [(set_attr "type" "arith") (set_attr "mode" "SI") @@ -1571,7 +1571,7 @@ (define_insn "*lshrsi3_byone" [(set (match_operand:SI 0 "register_operand" "=d") (lshiftrt:SI (match_operand:SI 1 "register_operand" "d") (match_operand:SI 2 "arith_operand" "I")))] - "(INTVAL (operands[2]) == 1)" + "operands[2] == const1_rtx" "srl\t%0,%1" [(set_attr "type" "arith") (set_attr "mode" "SI") -- 1.9.3