This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: How aggressive is CSE about removing redundant CC sets?
- From: Ulrich Weigand <weigand at i1 dot informatik dot uni-erlangen dot de>
- To: kazu at cs dot umass dot edu (Kazu Hirata)
- Cc: weigand at i1 dot informatik dot uni-erlangen dot de, gcc at gcc dot gnu dot org
- Date: Sun, 15 Feb 2004 03:27:45 +0100 (CET)
- Subject: Re: How aggressive is CSE about removing redundant CC sets?
Hi Kazu,
> > (Optionally, it may be beneficial to provide a third pattern that
> > has *only* the SET CC, and a (clobber (match_scratch)) to do away
> > with the main output; this will be chosen if you're performing the
> > operation only to look at the CC.)
>
> I'm sorry, I don't quite understand. Could you give me an example
> pattern? Something like this?
Most arithmetic instructions in the s390 backend follow the scheme of
having those three patterns, called XXX, XXX_cc, and XXX_cconly.
As a prototypical example here's the xordi3 patterns (reg 33 is
the condition code; the s390_match_ccmode stuff handles the fact
that more than one CCmode is acceptable for these insns):
This is the expander (just clobbers CC):
(define_insn "xordi3"
[(set (match_operand:DI 0 "register_operand" "=d,d")
(xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
(match_operand:DI 2 "general_operand" "d,m")))
(clobber (reg:CC 33))]
"TARGET_64BIT"
"@
xgr\t%0,%2
xg\t%0,%2"
[(set_attr "op_type" "RRE,RXY")])
The full pattern with two SETs:
(define_insn "*xordi3_cc"
[(set (reg 33)
(compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
(match_operand:DI 2 "general_operand" "d,m"))
(const_int 0)))
(set (match_operand:DI 0 "register_operand" "=d,d")
(xor:DI (match_dup 1) (match_dup 2)))]
"s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
"@
xgr\t%0,%2
xg\t%0,%2"
[(set_attr "op_type" "RRE,RXY")])
And the 'cconly' pattern that has a SET for CC and a CLOBBER
for the output of the arithmetical operation:
(define_insn "*xordi3_cconly"
[(set (reg 33)
(compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
(match_operand:DI 2 "general_operand" "d,m"))
(const_int 0)))
(clobber (match_scratch:DI 0 "=d,d"))]
"s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
"@
xgr\t%0,%2
xr\t%0,%2"
[(set_attr "op_type" "RRE,RXY")])
The advantage of the last is that it, like the first, is accepted
by single_set, and thus takes part in many optimization steps
the second pattern doesn't. It will be chosen by combine if only
the result of the comparison is needed.
Bye,
Ulrich
--
Dr. Ulrich Weigand
weigand@informatik.uni-erlangen.de