This is the mail archive of the
mailing list for the GCC project.
Re: help on adding new insns like min/max
- From: Ming Ouyang <mouyang at yahoo dot com>
- To: Dale Johannesen <dalej at apple dot com>
- Cc: Dale Johannesen <dalej at apple dot com>, gcc at gcc dot gnu dot org
- Date: Mon, 21 Oct 2002 17:34:20 -0700 (PDT)
- Subject: Re: help on adding new insns like min/max
I just found that macro doesn't always work well, for any complicated
operands like: max(a, ++b), max(a+b, c), max(a, foo(c)), gcc won't
use max insn for them, it only use max insn for max(a,b).
In addition, if I have more than one maxs/mins, it seems gcc will
not generate max/min for them, could you give me some help on that?
Thanks a lot.
--- Dale Johannesen <email@example.com> wrote:
> On Monday, October 21, 2002, at 04:05 PM, Ming Ouyang wrote:
> > I tried my gcc with definition of sminsi3/smaxsi3 and I dumpped
> > all debug info, gcc always treats min as a function call in my
> > test.c.00.rtl through test.c.30.dbr:
> > (call (mem:SI (symbol_ref/v:SI ("smin")) ))
> > I think once gcc found that is a function call, it would not
> > optimize it, am I right?
> > What I should get is something like "(smin: SI ...", is that right?
> > So probably I need to change something other than xxx.md?
> > Thanks.
> If you're using it as a function of course gcc will treat it as
> a function. It is not one of the standard C functions so gcc does
> not do anything special to it (and is not allowed to, that would
> break standard conformance). The usual way to get min/max functionality
> in C is to put a macro definition in a header file somewhere, something
> #define MAX(x,y) ((x>y) ? x : y)
> (watch out for ++ operators, improvement left as an exercise)
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site