re PR target/52294 ([ARM Thumb] generated asm code produces "branch out of range...
[gcc.git] / gcc / config / arm / thumb2.md
index 26dcbdde83e3d689caeb2912191e3f4b33edfe43..39a2138a689dce893285c5650f1730e615b4034f 100644 (file)
 (define_insn "*thumb2_movhi_insn"
   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r")
        (match_operand:HI 1 "general_operand"      "rI,n,r,m"))]
-  "TARGET_THUMB2"
+  "TARGET_THUMB2
+  && (register_operand (operands[0], HImode)
+     || register_operand (operands[1], HImode))"
   "@
    mov%?\\t%0, %1\\t%@ movhi
    movw%?\\t%0, %L1\\t%@ movhi
        (not:SI (match_operator:SI 1 "arm_comparison_operator"
                 [(match_operand 2 "cc_register" "") (const_int 0)])))]
   "TARGET_THUMB2"
-  "ite\\t%D1\;mov%D1\\t%0, #0\;mvn%d1\\t%0, #1"
+  "ite\\t%D1\;mvn%D1\\t%0, #0\;mvn%d1\\t%0, #1"
   [(set_attr "conds" "use")
    (set_attr "length" "10")]
 )
          (match_operand:SI 2 "low_reg_or_int_operand" "")]))]
   "TARGET_THUMB2
    && peep2_regno_dead_p(0, CC_REGNUM)
+   && (CONST_INT_P (operands[2]) || operands[1] == operands[0])
    && ((GET_CODE(operands[3]) != ROTATE && GET_CODE(operands[3]) != ROTATERT)
        || REG_P(operands[2]))"
   [(parallel
 )
 
 (define_insn "*thumb2_shiftsi3_short"
-  [(set (match_operand:SI   0 "low_register_operand" "=l")
+  [(set (match_operand:SI   0 "low_register_operand" "=l,l")
        (match_operator:SI  3 "shift_operator"
-        [(match_operand:SI 1 "low_register_operand"  "l")
-         (match_operand:SI 2 "low_reg_or_int_operand" "lM")]))
+        [(match_operand:SI 1 "low_register_operand"  "0,l")
+         (match_operand:SI 2 "low_reg_or_int_operand" "l,M")]))
    (clobber (reg:CC CC_REGNUM))]
   "TARGET_THUMB2 && reload_completed
    && ((GET_CODE(operands[3]) != ROTATE && GET_CODE(operands[3]) != ROTATERT)
         (if_then_else
            (and (ge (minus (match_dup 1) (pc)) (const_int 2))
                 (le (minus (match_dup 1) (pc)) (const_int 128))
-                (eq (symbol_ref ("which_alternative")) (const_int 0)))
+                (not (match_test "which_alternative")))
            (const_int 2)
            (const_int 8)))]
 )
         (if_then_else
            (and (ge (minus (match_dup 1) (pc)) (const_int 2))
                 (le (minus (match_dup 1) (pc)) (const_int 128))
-                (eq (symbol_ref ("which_alternative")) (const_int 0)))
+                (not (match_test "which_alternative")))
            (const_int 2)
            (const_int 8)))]
 )