@@ -5635,6 +5635,21 @@
}"
)
+;; For thumb1 split imm move [256-510] into mov [1-255] and add #255
+(define_split
+ [(set (match_operand:SI 0 "register_operand" "")
+ (match_operand:SI 1 "const_int_operand" ""))]
+ "TARGET_THUMB1 && satisfies_constraint_Pe (operands[1])"
+ [(set (match_dup 2) (match_dup 1))
+ (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 3)))]
+ "
+ {
+ operands[1] = GEN_INT (INTVAL (operands[1]) - 255);
+ operands[2] = can_create_pseudo_p () ? gen_reg_rtx (SImode) :
operands[0];
+ operands[3] = GEN_INT (255);
+ }"
+)
+
;; When generating pic, we need to load the symbol offset into a register.
;; So that the optimizer does not confuse this with a normal symbol load
;; we use an unspec. The offset will be loaded from a constant pool entry,
@@ -30,7 +30,7 @@
;; The following multi-letter normal constraints have been used:
;; in ARM/Thumb-2 state: Da, Db, Dc, Dn, Dl, DL, Dv, Dy, Di, Dt, Dz
-;; in Thumb-1 state: Pa, Pb, Pc, Pd
+;; in Thumb-1 state: Pa, Pb, Pc, Pd, Pe
;; in Thumb-2 state: Pj, PJ, Ps, Pt, Pu, Pv, Pw, Px, Py
;; The following memory constraints have been used:
@@ -172,6 +172,11 @@
(and (match_code "const_int")
(match_test "TARGET_THUMB1 && ival >= 0 && ival <= 7")))
+(define_constraint "Pe"
+ "@internal In Thumb-1 state a constant in the range 256 to +510"
+ (and (match_code "const_int")
+ (match_test "TARGET_THUMB1 && ival >= 256 && ival <= 510")))
+
(define_constraint "Ps"
"@internal In Thumb-2 state a constant in the range -255 to +255"
(and (match_code "const_int")
b/gcc/testsuite/gcc.target/arm/thumb1-imm.c
new file mode 100644
@@ -0,0 +1,10 @@
+/* Check for thumb1 imm [255-510] moves. */
+/* { dg-require-effective-target arm_thumb1_ok } */
+
+int f()
+{
+ return 257;
+}
+
+/* { dg-final { scan-assembler-not "ldr" } } */
+