AVR: Tweak register pressure for const_fixed compares against "M".

When comparing a 16-bit or 32-bit integer against a constant in
the range 0...0xff, constraint M is used because no scratch reg
is needed in that case.  Same can be done for fixed-point compares.

gcc/
	* config/avr/constraints.md (YMM): New constraint.
	* config/avr/avr.md (cmp<mode>3, *cmp<mode>3)
	(cbranch<mode>4_insn): Allow YMM where M is allowed.
This commit is contained in:
Georg-Johann Lay
2024-08-01 09:58:48 +02:00
parent df2b444a23
commit d050484797
2 changed files with 21 additions and 14 deletions

View File

@@ -6568,9 +6568,9 @@
;; "cmpha3" "cmpuha3"
(define_insn "cmp<mode>3"
[(set (reg:CC REG_CC)
(compare:CC (match_operand:ALL2 0 "register_operand" "!w ,r ,r,d ,r ,d,r")
(match_operand:ALL2 1 "nonmemory_operand" "Y00,Y00,r,s ,s ,M,n Ynn")))
(clobber (match_scratch:QI 2 "=X ,X ,X,&d,&d ,X,&d"))]
(compare:CC (match_operand:ALL2 0 "register_operand" "!w ,r ,r,d ,r ,d ,r")
(match_operand:ALL2 1 "nonmemory_operand" "Y00,Y00,r,s ,s ,M YMM,n Ynn")))
(clobber (match_scratch:QI 2 "=X ,X ,X,&d,&d,X ,&d"))]
"reload_completed"
{
switch (which_alternative)
@@ -6635,9 +6635,9 @@
;; "*cmpsa" "*cmpusa"
(define_insn "*cmp<mode>"
[(set (reg:CC REG_CC)
(compare:CC (match_operand:ALL4 0 "register_operand" "r ,r ,d,r ,r")
(match_operand:ALL4 1 "nonmemory_operand" "Y00,r ,M,M ,n Ynn")))
(clobber (match_scratch:QI 2 "=X ,X ,X,&d,&d"))]
(compare:CC (match_operand:ALL4 0 "register_operand" "r ,r ,d ,r")
(match_operand:ALL4 1 "nonmemory_operand" "Y00,r ,M YMM,n Ynn")))
(clobber (match_scratch:QI 2 "=X ,X ,X ,&d"))]
"reload_completed"
{
if (0 == which_alternative)
@@ -6647,8 +6647,8 @@
return avr_out_compare (insn, operands, NULL);
}
[(set_attr "length" "4,4,4,5,8")
(set_attr "adjust_len" "tstsi,*,compare,compare,compare")])
[(set_attr "length" "4,4,4,8")
(set_attr "adjust_len" "tstsi,*,compare,compare")])
;; A helper for avr_pass_ifelse::avr_rest_of_handle_ifelse().
@@ -6727,11 +6727,11 @@
[(set (pc)
(if_then_else
(match_operator 0 "ordered_comparison_operator"
[(match_operand:ALL4 1 "register_operand" "r ,r,d,r ,r")
(match_operand:ALL4 2 "nonmemory_operand" "Y00,r,M,M ,n Ynn")])
[(match_operand:ALL4 1 "register_operand" "r ,r,d ,r")
(match_operand:ALL4 2 "nonmemory_operand" "Y00,r,M YMM ,n Ynn")])
(label_ref (match_operand 3))
(pc)))
(clobber (match_scratch:QI 4 "=X ,X,X,&d,&d"))]
(clobber (match_scratch:QI 4 "=X ,X,X ,&d"))]
""
"#"
"reload_completed"
@@ -6772,11 +6772,11 @@
[(set (pc)
(if_then_else
(match_operator 0 "ordered_comparison_operator"
[(match_operand:ALL2 1 "register_operand" "!w ,r ,r,d ,r ,d,r")
(match_operand:ALL2 2 "nonmemory_operand" "Y00,Y00,r,s ,s ,M,n Ynn")])
[(match_operand:ALL2 1 "register_operand" "!w ,r ,r,d ,r ,d ,r")
(match_operand:ALL2 2 "nonmemory_operand" "Y00,Y00,r,s ,s ,M YMM,n Ynn")])
(label_ref (match_operand 3))
(pc)))
(clobber (match_scratch:QI 4 "=X ,X ,X,&d,&d,X,&d"))]
(clobber (match_scratch:QI 4 "=X ,X ,X,&d,&d,X ,&d"))]
""
"#"
"reload_completed"

View File

@@ -313,6 +313,13 @@
(and (match_code "const_fixed")
(match_test "IN_RANGE (INTVAL (avr_to_int_mode (op)), -63, 63)")))
;; Similar to "M", but for CONST_FIXED.
(define_constraint "YMM"
"Fixed-point constant in the range 0 @dots{} 0xff when viewed as CONST_INT."
(and (match_code "const_fixed")
(match_test "IN_RANGE (INTVAL (avr_to_int_mode (op)), 0, 0xff)")))
(define_constraint "Yil"
"Memory in the lower half of the I/O space."
(and (match_code "mem")