This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Semantics of PARALLEL that sets and uses CC0
- From: Steven Bosscher <stevenb dot gcc at gmail dot com>
- To: GCC Mailing List <gcc at gcc dot gnu dot org>, eric dot weddington at atmel dot com, Paolo Bonzini <bonzini at gnu dot org>
- Date: Mon, 9 Aug 2010 16:26:04 +0200
- Subject: Semantics of PARALLEL that sets and uses CC0
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