public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* pattern "s<code>_<mode>" not used when generating rtl for float   comparison on mips?
@ 2010-04-27 11:15 Amker.Cheng
  2010-04-27 13:12 ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Amker.Cheng @ 2010-04-27 11:15 UTC (permalink / raw)
  To: gcc

Hi :
There is a pattern "define_insn "s<code>_<mode>"" in mips md file, like

(define_insn "s<code>_<mode>"
  [(set (match_operand:CC 0 "register_operand" "=z")
	(swapped_fcond:CC (match_operand:SCALARF 1 "register_operand" "f")
		          (match_operand:SCALARF 2 "register_operand" "f")))]
  ""
  "c.<swapped_fcond>.<fmt>\t%Z0%2,%1"
  [(set_attr "type" "fcmp")
   (set_attr "mode" "FPSW")])

I am wondering whether this insn pattern would ever be used when generating
float comparison, Since we use cmp<mode> and branch expand to do the job
And comparison operation are normally followed by a branch.
Am i right?
Any idea? Thanks for helping.

-- 
Best Regards.

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

* Re: pattern "s<code>_<mode>" not used when generating rtl for float    comparison on mips?
  2010-04-27 11:15 pattern "s<code>_<mode>" not used when generating rtl for float comparison on mips? Amker.Cheng
@ 2010-04-27 13:12 ` Paolo Bonzini
  2010-04-28  8:31   ` Amker.Cheng
  0 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2010-04-27 13:12 UTC (permalink / raw)
  To: Amker.Cheng; +Cc: gcc

On 04/27/2010 11:42 AM, Amker.Cheng wrote:
> Hi :
> There is a pattern "define_insn "s<code>_<mode>"" in mips md file, like
>
> (define_insn "s<code>_<mode>"
>    [(set (match_operand:CC 0 "register_operand" "=z")
> 	(swapped_fcond:CC (match_operand:SCALARF 1 "register_operand" "f")
> 		          (match_operand:SCALARF 2 "register_operand" "f")))]
>    ""
>    "c.<swapped_fcond>.<fmt>\t%Z0%2,%1"
>    [(set_attr "type" "fcmp")
>     (set_attr "mode" "FPSW")])
>
> I am wondering whether this insn pattern would ever be used when generating
> float comparison, Since we use cmp<mode>  and branch expand to do the job
> And comparison operation are normally followed by a branch.
> Am i right?

You can get the RTL for these patterns when expanding stores like

    a = (b < c);

In this case, GCC tries to avoid a conditional branch and (I suppose you 
are on GCC <4.5) instead of cmp<mode> and b<cond> you go through 
cmp<mode> and s<cond>.  cmp<mode> does nothing but stashing away its 
operands, while s<cond> expands RTL for both the comparison and the 
above insn.

For GCC >=4.5 there is no cmp<mode> anymore, and branches and store go 
through cbranch<mode>4 and cstore<mode>4 respectively.  The logic 
however is the same, with cstore<mode>4 emitting the RTL for both the 
comparison and the conditional store.

Hope this helps,

Paolo

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

* Re: pattern "s<code>_<mode>" not used when generating rtl for float   comparison on mips?
  2010-04-27 13:12 ` Paolo Bonzini
@ 2010-04-28  8:31   ` Amker.Cheng
  2010-04-28  9:33     ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Amker.Cheng @ 2010-04-28  8:31 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: gcc

>
> You can get the RTL for these patterns when expanding stores like
>
>   a = (b < c);
>
> In this case, GCC tries to avoid a conditional branch and (I suppose you are
> on GCC <4.5) instead of cmp<mode> and b<cond> you go through cmp<mode> and
> s<cond>.  cmp<mode> does nothing but stashing away its operands, while
> s<cond> expands RTL for both the comparison and the above insn.

Thanks, and yes, I'm using GCC 4.4,
But gcc didn't work in this way for me, I tried piece of code like:

extern float a, b;
extern int c;
int main(void)
{
  c = (a < b);
  return 0;
}

after tracing cc1, found gcc would also do it with set/compare/jump/set code at
the end of function do_store_flag, i.e., unsing cmp<mode> and b<code> sequence.

-- 
Best Regards.

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

* Re: pattern "s<code>_<mode>" not used when generating rtl for float  comparison on mips?
  2010-04-28  8:31   ` Amker.Cheng
@ 2010-04-28  9:33     ` Paolo Bonzini
  2010-04-29 13:17       ` Amker.Cheng
  0 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2010-04-28  9:33 UTC (permalink / raw)
  To: Amker.Cheng; +Cc: gcc

On 04/28/2010 03:47 AM, Amker.Cheng wrote:
>>
>> You can get the RTL for these patterns when expanding stores like
>>
>>    a = (b < c);
>>
>> In this case, GCC tries to avoid a conditional branch and (I suppose you are
>> on GCC<4.5) instead of cmp<mode>  and b<cond>  you go through cmp<mode>  and
>> s<cond>.  cmp<mode>  does nothing but stashing away its operands, while
>> s<cond>  expands RTL for both the comparison and the above insn.
>
> Thanks, and yes, I'm using GCC 4.4,
> But gcc didn't work in this way for me, I tried piece of code like:
>
> extern float a, b;
> extern int c;
> int main(void)
> {
>    c = (a < b);
>    return 0;
> }
>
> after tracing cc1, found gcc would also do it with set/compare/jump/set code at
> the end of function do_store_flag, i.e., unsing cmp<mode>  and b<code>  sequence.

Indeed, looking at GCC 4.5 there's no cstore expander for floating-point 
variables.  Maybe you can make a patch! :-)

Paolo

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

* Re: pattern "s<code>_<mode>" not used when generating rtl for float  comparison on mips?
  2010-04-28  9:33     ` Paolo Bonzini
@ 2010-04-29 13:17       ` Amker.Cheng
  0 siblings, 0 replies; 5+ messages in thread
From: Amker.Cheng @ 2010-04-29 13:17 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: gcc

> Indeed, looking at GCC 4.5 there's no cstore expander for floating-point
> variables.  Maybe you can make a patch! :-)
>
yes, it seems gcc always generates set/compare/jump/set sequence,
then optimizes it out in if-convert pass. Maybe it was left behind by
early mips1, which has no conditional move instructions.

it is some kinda related with my current work, I'll try to see if I could
help with it after more study.

Thanks.

-- 
Best Regards.

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

end of thread, other threads:[~2010-04-29 13:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-27 11:15 pattern "s<code>_<mode>" not used when generating rtl for float comparison on mips? Amker.Cheng
2010-04-27 13:12 ` Paolo Bonzini
2010-04-28  8:31   ` Amker.Cheng
2010-04-28  9:33     ` Paolo Bonzini
2010-04-29 13:17       ` Amker.Cheng

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