+2003-06-04 Eric Botcazou <ebotcazou@libertysurf.fr>
+
+ PR optimization/10876
+ * config/sparc/sparc.h (CONST_OK_FOR_LETTER): Add
+ new 'O' constraint for constant 4096.
+ (CONST_DOUBLE_OK_FOR_LETTER_P): Likewise.
+ * config/sparc/sparc.md (adddi3 expander): Canonicalize pattern.
+ Do not transform into MINUS insn for constant 4096.
+ (*adddi3_sp64 insn): Canonicalize pattern. Add new alternative
+ for constant 4096 as third operand.
+ (addsi3 expander): Remove.
+ (*addsi3 insn): Rename into 'addsi3'. Canonicalize pattern. Add
+ new alternative for constant 4096 as third operand.
+ (subdi3 expander): Do not transform into PLUS insn for constant 4096.
+ (*subdi3_sp64 insn): Add new alternative for constant 4096 as third
+ operand.
+ (subsi3 expander): Remove.
+ (*subsi3 insn): Rename into 'subsi3'. Add new alternative for
+ constant 4096 as third operand.
+ * doc/md.texi (Machine Constraints): Document new 'O' constraint for
+ the SPARC port.
+
2003-06-03 Chris Demetriou <cgd@broadcom.com>
* config/mips/t-linux64 (CRTSTUFF_T_CFLAGS_S): Define.
`K' is used for constants which can be loaded with a single sethi insn.
`L' is used for the range of constants supported by the movcc insns.
`M' is used for the range of constants supported by the movrcc insns.
- `N' is like K, but for constants wider than 32 bits. */
+ `N' is like K, but for constants wider than 32 bits.
+ `O' is used for the range which is just 4096. */
#define SPARC_SIMM10_P(X) ((unsigned HOST_WIDE_INT) (X) + 0x200 < 0x400)
#define SPARC_SIMM11_P(X) ((unsigned HOST_WIDE_INT) (X) + 0x400 < 0x800)
: (C) == 'L' ? SPARC_SIMM11_P (VALUE) \
: (C) == 'M' ? SPARC_SIMM10_P (VALUE) \
: (C) == 'N' ? SPARC_SETHI_P (VALUE) \
+ : (C) == 'O' ? (VALUE) == 4096 \
: 0)
/* Similar, but for floating constants, and defining letters G and H.
#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
((C) == 'G' ? fp_zero_operand (VALUE, GET_MODE (VALUE)) \
: (C) == 'H' ? arith_double_operand (VALUE, DImode) \
+ : (C) == 'O' ? arith_double_4096_operand (VALUE, DImode) \
: 0)
/* Given an rtx X being reloaded into a reg required to be
;;- arithmetic instructions
(define_expand "adddi3"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (plus:DI (match_operand:DI 1 "arith_double_operand" "%r")
- (match_operand:DI 2 "arith_double_add_operand" "rHI")))]
+ [(set (match_operand:DI 0 "register_operand" "")
+ (plus:DI (match_operand:DI 1 "register_operand" "")
+ (match_operand:DI 2 "arith_double_add_operand" "")))]
""
{
- HOST_WIDE_INT i;
-
if (! TARGET_ARCH64)
{
emit_insn (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2,
gen_rtx_REG (CCmode, SPARC_ICC_REG)))));
DONE;
}
- if (arith_double_4096_operand(operands[2], DImode))
- {
- switch (GET_CODE (operands[1]))
- {
- case CONST_INT: i = INTVAL (operands[1]); break;
- case CONST_DOUBLE: i = CONST_DOUBLE_LOW (operands[1]); break;
- default:
- emit_insn (gen_rtx_SET (VOIDmode, operands[0],
- gen_rtx_MINUS (DImode, operands[1],
- GEN_INT(-4096))));
- DONE;
- }
- emit_insn (gen_movdi (operands[0], GEN_INT (i + 4096)));
- DONE;
- }
})
(define_insn_and_split "adddi3_insn_sp32"
[(set_attr "length" "2")])
(define_insn "*adddi3_sp64"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (plus:DI (match_operand:DI 1 "arith_double_operand" "%r")
- (match_operand:DI 2 "arith_double_operand" "rHI")))]
+ [(set (match_operand:DI 0 "register_operand" "=r,r")
+ (plus:DI (match_operand:DI 1 "register_operand" "%r,r")
+ (match_operand:DI 2 "arith_double_add_operand" "rHI,O")))]
"TARGET_ARCH64"
- "add\t%1, %2, %0")
-
-(define_expand "addsi3"
- [(set (match_operand:SI 0 "register_operand" "=r,d")
- (plus:SI (match_operand:SI 1 "arith_operand" "%r,d")
- (match_operand:SI 2 "arith_add_operand" "rI,d")))]
- ""
-{
- if (arith_4096_operand(operands[2], SImode))
- {
- if (GET_CODE (operands[1]) == CONST_INT)
- emit_insn (gen_movsi (operands[0],
- GEN_INT (INTVAL (operands[1]) + 4096)));
- else
- emit_insn (gen_rtx_SET (VOIDmode, operands[0],
- gen_rtx_MINUS (SImode, operands[1],
- GEN_INT(-4096))));
- DONE;
- }
-})
+ "@
+ add\t%1, %2, %0
+ sub\t%1, -%2, %0")
-(define_insn "*addsi3"
- [(set (match_operand:SI 0 "register_operand" "=r,d")
- (plus:SI (match_operand:SI 1 "arith_operand" "%r,d")
- (match_operand:SI 2 "arith_operand" "rI,d")))]
+(define_insn "addsi3"
+ [(set (match_operand:SI 0 "register_operand" "=r,r,d")
+ (plus:SI (match_operand:SI 1 "register_operand" "%r,r,d")
+ (match_operand:SI 2 "arith_add_operand" "rI,O,d")))]
""
"@
add\t%1, %2, %0
+ sub\t%1, -%2, %0
fpadd32s\t%1, %2, %0"
- [(set_attr "type" "*,fp")])
+ [(set_attr "type" "*,*,fp")])
(define_insn "*cmp_cc_plus"
[(set (reg:CC_NOOV 100)
[(set_attr "type" "compare")])
(define_expand "subdi3"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (minus:DI (match_operand:DI 1 "register_operand" "r")
- (match_operand:DI 2 "arith_double_add_operand" "rHI")))]
+ [(set (match_operand:DI 0 "register_operand" "")
+ (minus:DI (match_operand:DI 1 "register_operand" "")
+ (match_operand:DI 2 "arith_double_add_operand" "")))]
""
{
if (! TARGET_ARCH64)
gen_rtx_REG (CCmode, SPARC_ICC_REG)))));
DONE;
}
- if (arith_double_4096_operand(operands[2], DImode))
- {
- emit_insn (gen_rtx_SET (VOIDmode, operands[0],
- gen_rtx_PLUS (DImode, operands[1],
- GEN_INT(-4096))));
- DONE;
- }
})
(define_insn_and_split "*subdi3_sp32"
[(set_attr "length" "2")])
(define_insn "*subdi3_sp64"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (minus:DI (match_operand:DI 1 "register_operand" "r")
- (match_operand:DI 2 "arith_double_operand" "rHI")))]
+ [(set (match_operand:DI 0 "register_operand" "=r,r")
+ (minus:DI (match_operand:DI 1 "register_operand" "r,r")
+ (match_operand:DI 2 "arith_double_add_operand" "rHI,O")))]
"TARGET_ARCH64"
- "sub\t%1, %2, %0")
-
-(define_expand "subsi3"
- [(set (match_operand:SI 0 "register_operand" "=r,d")
- (minus:SI (match_operand:SI 1 "register_operand" "r,d")
- (match_operand:SI 2 "arith_add_operand" "rI,d")))]
- ""
-{
- if (arith_4096_operand(operands[2], SImode))
- {
- emit_insn (gen_rtx_SET (VOIDmode, operands[0],
- gen_rtx_PLUS (SImode, operands[1],
- GEN_INT(-4096))));
- DONE;
- }
-})
+ "@
+ sub\t%1, %2, %0
+ add\t%1, -%2, %0")
-(define_insn "*subsi3"
- [(set (match_operand:SI 0 "register_operand" "=r,d")
- (minus:SI (match_operand:SI 1 "register_operand" "r,d")
- (match_operand:SI 2 "arith_operand" "rI,d")))]
+(define_insn "subsi3"
+ [(set (match_operand:SI 0 "register_operand" "=r,r,d")
+ (minus:SI (match_operand:SI 1 "register_operand" "r,r,d")
+ (match_operand:SI 2 "arith_add_operand" "rI,O,d")))]
""
"@
sub\t%1, %2, %0
+ add\t%1, -%2, %0
fpsub32s\t%1, %2, %0"
- [(set_attr "type" "*,fp")])
+ [(set_attr "type" "*,*,fp")])
(define_insn "*cmp_minus_cc"
[(set (reg:CC_NOOV 100)