--- gcc/config/m68k.md 2018/04/24 16:54:39 1.1.1.2 +++ gcc/config/m68k.md 2018/04/24 17:01:55 1.1.1.5 @@ -714,7 +714,10 @@ (define_insn "" [(set (match_operand:SI 0 "general_operand" "=g") (const_int 0))] - "" + ;; clr insns on 68000 read before writing. + ;; This isn't so on the 68010, but we have no alternative for it. + "(TARGET_68020 + || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))" "* { if (ADDRESS_REG_P (operands[0])) @@ -749,7 +752,12 @@ { if (operands[1] == const0_rtx && (DATA_REG_P (operands[0]) - || GET_CODE (operands[0]) == MEM)) + || GET_CODE (operands[0]) == MEM) + /* clr insns on 68000 read before writing. + This isn't so on the 68010, but we have no alternative for it. */ + && (TARGET_68020 + || !(GET_CODE (operands[0]) == MEM + && MEM_VOLATILE_P (operands[0])))) return \"clr%.l %0\"; else if (DATA_REG_P (operands[0]) && INTVAL (operands[1]) < 128 @@ -791,7 +799,12 @@ { if (operands[1] == const0_rtx && (DATA_REG_P (operands[0]) - || GET_CODE (operands[0]) == MEM)) + || GET_CODE (operands[0]) == MEM) + /* clr insns on 68000 read before writing. + This isn't so on the 68010, but we have no alternative for it. */ + && (TARGET_68020 + || !(GET_CODE (operands[0]) == MEM + && MEM_VOLATILE_P (operands[0])))) return \"clr%.w %0\"; else if (DATA_REG_P (operands[0]) && INTVAL (operands[1]) < 128 @@ -856,7 +869,12 @@ { if (operands[1] == const0_rtx && (DATA_REG_P (operands[0]) - || GET_CODE (operands[0]) == MEM)) + || GET_CODE (operands[0]) == MEM) + /* clr insns on 68000 read before writing. + This isn't so on the 68010, but we have no alternative for it. */ + && (TARGET_68020 + || !(GET_CODE (operands[0]) == MEM + && MEM_VOLATILE_P (operands[0])))) return \"clr%.w %0\"; } return \"move%.w %1,%0\"; @@ -892,11 +910,20 @@ output_asm_insn (\"move%.w %1,%-\;move%.b %2,%0\;addq%.w %#2,%3\", xoperands); return \"\"; } - if (operands[1] == const0_rtx) - return \"clr%.b %0\"; - if (GET_CODE (operands[1]) == CONST_INT - && INTVAL (operands[1]) == -1) - return \"st %0\"; + /* clr and st insns on 68000 read before writing. + This isn't so on the 68010, but we have no alternative for it. */ + if (TARGET_68020 + || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))) + { + if (operands[1] == const0_rtx) + return \"clr%.b %0\"; + if (GET_CODE (operands[1]) == CONST_INT + && INTVAL (operands[1]) == -1) + { + CC_STATUS_INIT; + return \"st %0\"; + } + } if (GET_CODE (operands[1]) != CONST_INT && CONSTANT_P (operands[1])) return \"move%.l %1,%0\"; if (ADDRESS_REG_P (operands[0]) || ADDRESS_REG_P (operands[1])) @@ -910,7 +937,11 @@ "" "* { - if (operands[1] == const0_rtx) + if (operands[1] == const0_rtx + /* clr insns on 68000 read before writing. + This isn't so on the 68010, but we have no alternative for it. */ + && (TARGET_68020 + || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))) return \"clr%.b %0\"; return \"move%.b %1,%0\"; }") @@ -1084,7 +1115,12 @@ "* { if (GET_CODE (operands[0]) == REG) - return \"move%.l %1,%0\"; + { + /* Must clear condition codes, since the mov.l bases them on + the entire 32 bits, not just the desired 8 bits. */ + CC_STATUS_INIT; + return \"move%.l %1,%0\"; + } if (GET_CODE (operands[1]) == MEM) operands[1] = adj_offsettable_operand (operands[1], 3); return \"move%.b %1,%0\"; @@ -1100,9 +1136,19 @@ if (GET_CODE (operands[0]) == REG && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[1]) == CONST_INT)) - return \"move%.w %1,%0\"; + { + /* Must clear condition codes, since the mov.w bases them on + the entire 16 bits, not just the desired 8 bits. */ + CC_STATUS_INIT; + return \"move%.w %1,%0\"; + } if (GET_CODE (operands[0]) == REG) - return \"move%.l %1,%0\"; + { + /* Must clear condition codes, since the mov.l bases them on + the entire 32 bits, not just the desired 8 bits. */ + CC_STATUS_INIT; + return \"move%.l %1,%0\"; + } if (GET_CODE (operands[1]) == MEM) operands[1] = adj_offsettable_operand (operands[1], 1); return \"move%.b %1,%0\"; @@ -1116,7 +1162,12 @@ "* { if (GET_CODE (operands[0]) == REG) - return \"move%.l %1,%0\"; + { + /* Must clear condition codes, since the mov.l bases them on + the entire 32 bits, not just the desired 8 bits. */ + CC_STATUS_INIT; + return \"move%.l %1,%0\"; + } if (GET_CODE (operands[1]) == MEM) operands[1] = adj_offsettable_operand (operands[1], 2); return \"move%.w %1,%0\"; @@ -1201,9 +1252,13 @@ else if (GET_CODE (operands[0]) == MEM && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC) { - if (REGNO (XEXP (XEXP (operands[0], 0), 0)) - == STACK_POINTER_REGNUM) - return \"clr%.w %-\;move%.b %1,%0\"; + if (REGNO (XEXP (XEXP (operands[0], 0), 0)) == STACK_POINTER_REGNUM) + { + output_asm_insn (\"clr%.w %-\", operands); + operands[0] = gen_rtx (MEM, GET_MODE (operands[0]), + plus_constant (stack_pointer_rtx, 1)); + return \"move%.b %1,%0\"; + } else return \"move%.b %1,%0\;clr%.b %0\"; } @@ -2595,7 +2650,9 @@ (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m") (const_int 24))))] "(GET_CODE (operands[0]) == CONST_INT - && (INTVAL (operands[0]) & ~0xff) == 0)" + && (INTVAL (operands[0]) & ~0xff) == 0 + && GET_CODE (XEXP (operands[1], 0)) != POST_INC + && GET_CODE (XEXP (operands[1], 0)) != PRE_DEC)" "* cc_status.flags |= CC_REVERSED; #ifdef HPUX_ASM return \"cmp%.b %1,%0\"; @@ -2609,7 +2666,9 @@ (const_int 24)) (match_operand:QI 1 "general_operand" "i")))] "(GET_CODE (operands[1]) == CONST_INT - && (INTVAL (operands[1]) & ~0xff) == 0)" + && (INTVAL (operands[1]) & ~0xff) == 0 + && GET_CODE (XEXP (operands[0], 0)) != POST_INC + && GET_CODE (XEXP (operands[0], 0)) != PRE_DEC)" "* #ifdef HPUX_ASM return \"cmp%.b %0,%1\"; @@ -2623,7 +2682,9 @@ (ashiftrt:SI (match_operand:SI 1 "memory_operand" "m") (const_int 24))))] "(GET_CODE (operands[0]) == CONST_INT - && ((INTVAL (operands[0]) + 0x80) & ~0xff) == 0)" + && ((INTVAL (operands[0]) + 0x80) & ~0xff) == 0 + && GET_CODE (XEXP (operands[1], 0)) != POST_INC + && GET_CODE (XEXP (operands[1], 0)) != PRE_DEC)" "* cc_status.flags |= CC_REVERSED; #ifdef HPUX_ASM return \"cmp%.b %1,%0\"; @@ -2637,7 +2698,9 @@ (const_int 24)) (match_operand:QI 1 "general_operand" "i")))] "(GET_CODE (operands[1]) == CONST_INT - && ((INTVAL (operands[1]) + 0x80) & ~0xff) == 0)" + && ((INTVAL (operands[1]) + 0x80) & ~0xff) == 0 + && GET_CODE (XEXP (operands[0], 0)) != POST_INC + && GET_CODE (XEXP (operands[0], 0)) != PRE_DEC)" "* #ifdef HPUX_ASM return \"cmp%.b %0,%1\"; @@ -2829,6 +2892,7 @@ || ! mode_dependent_address_p (XEXP (operands[1], 0)))" "* { + cc_status.flags |= CC_NOT_NEGATIVE; if (REG_P (operands[1])) { if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32) @@ -2893,7 +2957,11 @@ (match_operand:SI 2 "general_operand" "di,di") (match_operand:SI 3 "general_operand" "di,di")))] "TARGET_68020 && TARGET_BITFIELD" - "bfextu %1{%b3:%b2},%0") + "* +{ + cc_status.flags |= CC_NOT_NEGATIVE; + return \"bfextu %1{%b3:%b2},%0\"; +}") (define_insn "" [(set (zero_extract:SI (match_operand:QI 0 "nonimmediate_operand" "+o,d") @@ -2961,7 +3029,11 @@ (match_operand:SI 2 "general_operand" "di") (match_operand:SI 3 "general_operand" "di")))] "TARGET_68020 && TARGET_BITFIELD" - "bfextu %1{%b3:%b2},%0") + "* +{ + cc_status.flags |= CC_NOT_NEGATIVE; + return \"bfextu %1{%b3:%b2},%0\"; +}") (define_insn "" [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "+d") @@ -3632,6 +3704,10 @@ (use (label_ref (match_operand 1 "" "")))] "" "* +{ +#ifdef ASM_RETURN_CASE_JUMP + ASM_RETURN_CASE_JUMP; +#else #ifdef SGS #ifdef ASM_OUTPUT_CASE_LABEL return \"jmp 6(%%pc,%0.w)\"; @@ -3645,7 +3721,8 @@ return \"jmp pc@(2,%0:w)\"; #endif #endif -") +#endif /* no ASM_RETURN_CASE_JUMP */ +}") ;; Unconditional and other jump instructions (define_insn "jump" @@ -3663,7 +3740,7 @@ (define_insn "" [(set (pc) (if_then_else - (ne (compare (plus:HI (match_operand:HI 0 "general_operand" "g") + (ne (compare (plus:HI (match_operand:HI 0 "general_operand" "=g") (const_int -1)) (const_int -1)) (const_int 0)) @@ -3708,7 +3785,7 @@ (define_insn "" [(set (pc) (if_then_else - (ne (compare (plus:SI (match_operand:SI 0 "general_operand" "g") + (ne (compare (plus:SI (match_operand:SI 0 "general_operand" "=g") (const_int -1)) (const_int -1)) (const_int 0)) @@ -3756,7 +3833,7 @@ (define_insn "" [(set (pc) (if_then_else - (ge (plus:SI (match_operand:SI 0 "general_operand" "g") + (ge (plus:SI (match_operand:SI 0 "general_operand" "=g") (const_int -1)) (const_int 0)) (label_ref (match_operand 1 "" ""))