This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: implement negdi2 on frv
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: 05 Dec 2003 23:32:17 -0200
- Subject: Re: implement negdi2 on frv
- Organization: GCC Team, Red Hat
- References: <ord6bg5719.fsf@livre.redhat.lsd.ic.unicamp.br><20031126200000.GA29276@redhat.com>
On Nov 26, 2003, Richard Henderson <rth@redhat.com> wrote:
> On Tue, Nov 25, 2003 at 10:04:50PM -0200, Alexandre Oliva wrote:
>> +(define_insn_and_split "*negdi2_internal"
>> + [(set (match_operand:DI 0 "integer_register_operand" "=&e,e")
>> + (neg:DI (match_operand:DI 1 "integer_register_operand" "e,0")))
>> + (clobber (match_operand:CC 2 "icc_operand" "=t,t"))]
> Should use match_scratch. Then you don't need the expander.
Ugh! Of course. I'll blame it on the author of the code I
shamelessly cut&pasted :-) The patch below fixes the original code
and adds negdi as you suggest. Ok?
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* config/frv/frv.md (subdi2): Merge with _internal insn_and_split,
by using match_scratch.
(negdi2): New.
Index: gcc/config/frv/frv.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/frv/frv.md,v
retrieving revision 1.5
diff -u -p -r1.5 frv.md
--- gcc/config/frv/frv.md 5 Oct 2003 13:34:44 -0000 1.5
+++ gcc/config/frv/frv.md 6 Dec 2003 01:31:41 -0000
@@ -2754,22 +2754,11 @@
;; Subtraction No need to worry about constants, since the compiler
;; canonicalizes them into adddi3's.
-(define_expand "subdi3"
- [(parallel [(set (match_operand:DI 0 "integer_register_operand" "")
- (minus:DI (match_operand:DI 1 "integer_register_operand" "")
- (match_operand:DI 2 "integer_register_operand" "")))
- (clobber (match_dup 3))])]
- ""
- "
-{
- operands[3] = gen_reg_rtx (CCmode);
-}")
-
-(define_insn_and_split "*subdi3_internal"
+(define_insn_and_split "subdi3"
[(set (match_operand:DI 0 "integer_register_operand" "=&e,e,e")
(minus:DI (match_operand:DI 1 "integer_register_operand" "e,0,e")
(match_operand:DI 2 "integer_register_operand" "e,e,0")))
- (clobber (match_operand:CC 3 "icc_operand" "=t,t,t"))]
+ (clobber (match_scratch:CC 3 "=t,t,t"))]
""
"#"
"reload_completed"
@@ -2841,6 +2830,31 @@
subx %1,%.,%0,%3"
[(set_attr "length" "4")
(set_attr "type" "int")])
+
+(define_insn_and_split "negdi2"
+ [(set (match_operand:DI 0 "integer_register_operand" "=&e,e")
+ (neg:DI (match_operand:DI 1 "integer_register_operand" "e,0")))
+ (clobber (match_scratch:CC 2 "=t,t"))]
+ ""
+ "#"
+ "reload_completed"
+ [(match_dup 3)
+ (match_dup 4)]
+ "
+{
+ rtx op0_high = gen_highpart (SImode, operands[0]);
+ rtx op1_high = gen_rtx_REG (SImode, GPR_FIRST);
+ rtx op2_high = gen_highpart (SImode, operands[1]);
+ rtx op0_low = gen_lowpart (SImode, operands[0]);
+ rtx op1_low = op1_high;
+ rtx op2_low = gen_lowpart (SImode, operands[1]);
+ rtx op3 = operands[2];
+
+ operands[3] = gen_subdi3_lower (op0_low, op1_low, op2_low, op3);
+ operands[4] = gen_subdi3_upper (op0_high, op1_high, op2_high, op3);
+}"
+ [(set_attr "length" "8")
+ (set_attr "type" "multi")])
;; Multiplication (same size)
;; (define_insn "muldi3"
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer