public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paul Koning <paul_koning@dell.com>
To: Richard Henderson <rth@redhat.com>
Cc: "Paulo J. Matos" <pocmatos@gmail.com>, <gcc@gcc.gnu.org>
Subject: Re: splitting add instructions
Date: Mon, 18 Jul 2011 17:31:00 -0000	[thread overview]
Message-ID: <948EFF37-272F-4ED4-AF6D-BFA05D8D6DF6@dell.com> (raw)
In-Reply-To: <4E246502.6070107@redhat.com>


On Jul 18, 2011, at 12:53 PM, Richard Henderson wrote:

> On 07/18/2011 08:01 AM, Paulo J. Matos wrote:
>> The problem is, if addhi3 expands into two insn:
>> (define_insn "addqi3"
>>   [(set (match_operand:HI 0 "nonimmediate_operand" "=c")
>>         (plus:HI (match_operand:HI 1 "general_operand" "%0")
>>                  (match_operand:HI 2 "general_operand" "cwmi")))]
>>   "get_attr_CARRY(insn) == 0"
>>   "add  %b0,%b2")
>> 
>> (define_insn "addqi3_carry"
>>   [(set (match_operand:HI 0 "nonimmediate_operand" "=c")
>>         (plus:HI (match_operand:HI 1 "general_operand" "%0")
>>                  (match_operand:HI 2 "general_operand" "cwmi")))]
>>   "get_attr_CARRY(insn) == 1"
>>   "addc %t0,%t2")
>> 
>> _One_ of the problems with this is that if GCC sees that op2 is 0, it will remove the insn because it will see: R0 = R0 + 0. However, it can't do this in this specific case because the plus is actually also adding the carry flag.
>> 
>> Any suggestions on how to deal with this situation?
> 
> You need to specifically represent the other output, i.e. the carry flag.
> 
> Depending on the constraints of your processor, you may or may not be able
> to expose this before reload.  Reload requires the ability to issue move
> instructions (all of loads, stores, reg-reg) and addition instructions.
> It must be able to do this between any pair of instructions in order to
> handle register spilling.  Therefore in order to expose the carry flag
> before reload, you must have an add instruction that does not modify the
> carry. Some processors have this in the form of a "load-effective-address"
> instruction.

Why an add instruction?  Is that in the case where address arithmetic requires separate adds?  If the machine is CISC, then I would think that reload just needs to be able to generate loads and stores that don't modify the carry, which would be a different requirement.  For example, on a pdp11 load/store (move) has that property, while add doesn't (it always touches carry).

"Specifically represent... the carry flag" means using the CCmode style of condition code handling, right?

	paul


  reply	other threads:[~2011-07-18 17:29 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-18 16:49 Paulo J. Matos
2011-07-18 16:59 ` Richard Henderson
2011-07-18 17:31   ` Paul Koning [this message]
2011-07-18 21:20     ` Richard Henderson
2011-07-19  8:27       ` Paulo J. Matos
2011-07-19 10:21         ` Paulo J. Matos
2011-07-19 15:42           ` Richard Henderson
2011-07-19 15:58             ` Paulo J. Matos
2011-07-19 16:08             ` Paulo J. Matos
2011-07-19 16:43               ` Richard Henderson
2011-07-19 12:57         ` Paul Koning
2011-07-19  8:30   ` Paulo J. Matos
2011-07-19 10:30   ` Paulo J. Matos
2011-07-19 10:52     ` Paulo J. Matos
2011-07-19 15:06   ` Paulo J. Matos
2011-07-19 15:09     ` DJ Delorie
2011-07-19 15:21       ` Paulo J. Matos
2011-07-19 15:42         ` Richard Henderson
2011-07-19 15:42           ` Paulo J. Matos
2011-07-18 17:29 ` Ian Lance Taylor
2011-07-19  8:49   ` Paulo J. Matos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=948EFF37-272F-4ED4-AF6D-BFA05D8D6DF6@dell.com \
    --to=paul_koning@dell.com \
    --cc=gcc@gcc.gnu.org \
    --cc=pocmatos@gmail.com \
    --cc=rth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).