public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Semantics of PARALLEL that sets and uses CC0
@ 2010-08-09 17:53 Steven Bosscher
  2010-08-09 18:00 ` Ulrich Weigand
  0 siblings, 1 reply; 4+ messages in thread
From: Steven Bosscher @ 2010-08-09 17:53 UTC (permalink / raw)
  To: GCC Mailing List, eric.weddington, Paolo Bonzini

Hello,

Forgive me if I overlooked it, but I can't find in the manuals what
the semantics would be of the following define_expand, from avr.md:

(define_expand "cbranchsi4"
  [(parallel [(set (cc0)
                   (compare (match_operand:SI 1 "register_operand" "")
                            (match_operand:SI 2 "nonmemory_operand" "")))
              (clobber (match_scratch:QI 4 ""))])
   (set (pc)
        (if_then_else
              (match_operator 0 "ordered_comparison_operator" [(cc0)
                                                               (const_int 0)])
              (label_ref (match_operand 3 "" ""))
              (pc)))]
 "")

The expander performs a SET of CC0 in the first pattern inside the
PARALLEL, and there is a USE of CC0 in the second pattern of the
PARALLEL.

The manual says this about PARALLELs:

//QUOTE//
``In parallel'' means that first all the values used in the individual
side-effects are computed, and second all the actual side-effects are
performed.  For example,

@smallexample
(parallel [(set (reg:SI 1) (mem:SI (reg:SI 1)))
           (set (mem:SI (reg:SI 1)) (reg:SI 1))])
@end smallexample

@noindent
says unambiguously that the values of hard register 1 and the memory
location addressed by it are interchanged.  In both places where
@code{(reg:SI 1)} appears as a memory address it refers to the value
in register 1 @emph{before} the execution of the insn.
//QUOTE//

Applied to the AVR expander, this seems to indicate that the USE of
CC0 refers to the value of CC0 *before* the SET of CC0 in the first
pattern of the PARALLEL. But I think the intent of the expander is to
use the result of the compare. What am I missing?

This was coded by Paolo in r147425:

147425    bonzini (define_expand "cbranchsi4"
147425    bonzini   [(parallel [(set (cc0)
147425    bonzini                  (compare (match_operand:SI 1
"register_operand" "")
147425    bonzini                           (match_operand:SI 2
"nonmemory_operand" "")))
147425    bonzini             (clobber (match_scratch:QI 4 ""))])
147425    bonzini    (set (pc)
147425    bonzini         (if_then_else
147425    bonzini               (match_operator 0
"ordered_comparison_operator" [(cc0)
147425    bonzini
          (const_int 0)])
147425    bonzini               (label_ref (match_operand 3 "" ""))
147425    bonzini

Paolo, this wouldn't be my first stupid question about RTL, but I
don't understand this expander :-)
Help?

Ciao!
Steven

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Semantics of PARALLEL that sets and uses CC0
  2010-08-09 17:53 Semantics of PARALLEL that sets and uses CC0 Steven Bosscher
@ 2010-08-09 18:00 ` Ulrich Weigand
  2010-08-09 20:57   ` Paolo Bonzini
  2010-08-09 21:04   ` Steven Bosscher
  0 siblings, 2 replies; 4+ messages in thread
From: Ulrich Weigand @ 2010-08-09 18:00 UTC (permalink / raw)
  To: Steven Bosscher; +Cc: GCC Mailing List, eric.weddington, Paolo Bonzini

Steven Bosscher wrote:

> Forgive me if I overlooked it, but I can't find in the manuals what
> the semantics would be of the following define_expand, from avr.md:
> 
> (define_expand "cbranchsi4"
>   [(parallel [(set (cc0)
>                    (compare (match_operand:SI 1 "register_operand" "")
>                             (match_operand:SI 2 "nonmemory_operand" "")))
>               (clobber (match_scratch:QI 4 ""))])
>    (set (pc)
>         (if_then_else
>               (match_operator 0 "ordered_comparison_operator" [(cc0)
>                                                                (const_int 0)])
>               (label_ref (match_operand 3 "" ""))
>               (pc)))]
>  "")
> 
> The expander performs a SET of CC0 in the first pattern inside the
> PARALLEL, and there is a USE of CC0 in the second pattern of the
> PARALLEL.

That's incorrect; the second pattern of the PARALLEL is just a CLOBBER.

The USE of CC0 happens in a completely separate second INSN that is
emitted by this define_expand.  (Note that as opposed to define_insn,
define_expand can emit more than a single insn.)

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Semantics of PARALLEL that sets and uses CC0
  2010-08-09 18:00 ` Ulrich Weigand
@ 2010-08-09 20:57   ` Paolo Bonzini
  2010-08-09 21:04   ` Steven Bosscher
  1 sibling, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2010-08-09 20:57 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: Steven Bosscher, GCC Mailing List, eric.weddington

On 08/09/2010 01:39 PM, Ulrich Weigand wrote:
>> (define_expand "cbranchsi4"
>>    [(parallel [(set (cc0)
>>                     (compare (match_operand:SI 1 "register_operand" "")
>>                              (match_operand:SI 2 "nonmemory_operand" "")))
>>                (clobber (match_scratch:QI 4 ""))])
>>     (set (pc)
>>          (if_then_else
>>                (match_operator 0 "ordered_comparison_operator" [(cc0)
>>                                                                 (const_int 0)])
>>                (label_ref (match_operand 3 "" ""))
>>                (pc)))]
>>   "")
>>
>
> [...] the second pattern of the PARALLEL is just a CLOBBER.
>
> The USE of CC0 happens in a completely separate second INSN that is
> emitted by this define_expand.  (Note that as opposed to define_insn,
> define_expand can emit more than a single insn.)

Yeah, that's the case.  What my patch did was just to combine the 
PARALLEL that the old cmpsi patterns produced (cc0 set), and the SET of 
the old bCC patterns (cc0 use).

In fact, having a cc0 set not _followed_ by a cc0 use would totally 
break every other RTL pass.

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Semantics of PARALLEL that sets and uses CC0
  2010-08-09 18:00 ` Ulrich Weigand
  2010-08-09 20:57   ` Paolo Bonzini
@ 2010-08-09 21:04   ` Steven Bosscher
  1 sibling, 0 replies; 4+ messages in thread
From: Steven Bosscher @ 2010-08-09 21:04 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: GCC Mailing List, eric.weddington, Paolo Bonzini

On Mon, Aug 9, 2010 at 7:39 PM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
> That's incorrect; the second pattern of the PARALLEL is just a CLOBBER.

Ah, parse error :-)
Thanks for your help!

Ciao!
Steven

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-08-09 18:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-09 17:53 Semantics of PARALLEL that sets and uses CC0 Steven Bosscher
2010-08-09 18:00 ` Ulrich Weigand
2010-08-09 20:57   ` Paolo Bonzini
2010-08-09 21:04   ` Steven Bosscher

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).