* Re: help on adding new insns like min/max [not found] <441B9D0E-E548-11D6-8BE6-000393D76DAA@apple.com> @ 2002-10-21 17:39 ` Ming Ouyang 2002-10-21 18:02 ` Dale Johannesen 0 siblings, 1 reply; 12+ messages in thread From: Ming Ouyang @ 2002-10-21 17:39 UTC (permalink / raw) To: gcc; +Cc: Dale Johannesen 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. --- Dale Johannesen <dalej@apple.com> wrote: > > On Monday, October 21, 2002, at 03:18 PM, Ming Ouyang wrote: > > > Dale, > > > > Thanks for your reply, but I wonder how gcc will handle code like: > > c = min(a, b) > > Does min/max will be treated as builtins? Or can you demonstrate > > how to make gcc to use sminsi3/smaxsi3... to use min/max insns for > > code like that? > > The optimization phases should create min/max from simpler RTL. > See noce_try_minmax in ifcvt.c. That won't necessarily handle > whatever case you want to handle, but it will give you an idea. > __________________________________________________ Do you Yahoo!? Y! Web Hosting - Let the expert host your web site http://webhosting.yahoo.com/ ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: help on adding new insns like min/max 2002-10-21 17:39 ` help on adding new insns like min/max Ming Ouyang @ 2002-10-21 18:02 ` Dale Johannesen 2002-10-21 18:21 ` Ming Ouyang 2002-10-21 20:42 ` Ming Ouyang 0 siblings, 2 replies; 12+ messages in thread From: Dale Johannesen @ 2002-10-21 18:02 UTC (permalink / raw) To: Ming Ouyang; +Cc: Dale Johannesen, gcc 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 like #define MAX(x,y) ((x>y) ? x : y) (watch out for ++ operators, improvement left as an exercise) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: help on adding new insns like min/max 2002-10-21 18:02 ` Dale Johannesen @ 2002-10-21 18:21 ` Ming Ouyang 2002-10-21 20:42 ` Ming Ouyang 1 sibling, 0 replies; 12+ messages in thread From: Ming Ouyang @ 2002-10-21 18:21 UTC (permalink / raw) To: gcc; +Cc: Dale Johannesen Yes, you are totally right and I'm misled by the abs implemention in our gcc compiler (I don't know who added support for the abs insn), it can support "abs(a)" and will translate it into one single abs insn. Now it seems that guy did something really complicated. Thank you so much :) Ming --- Dale Johannesen <dalej@apple.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 > like > #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 http://webhosting.yahoo.com/ ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: help on adding new insns like min/max 2002-10-21 18:02 ` Dale Johannesen 2002-10-21 18:21 ` Ming Ouyang @ 2002-10-21 20:42 ` Ming Ouyang 2002-10-21 23:00 ` Andrew Pinski 1 sibling, 1 reply; 12+ messages in thread From: Ming Ouyang @ 2002-10-21 20:42 UTC (permalink / raw) To: Dale Johannesen; +Cc: Dale Johannesen, gcc Dale, 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. Ming --- Dale Johannesen <dalej@apple.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 > like > #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 http://webhosting.yahoo.com/ ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: help on adding new insns like min/max 2002-10-21 20:42 ` Ming Ouyang @ 2002-10-21 23:00 ` Andrew Pinski 2002-10-21 23:27 ` Ming Ouyang 0 siblings, 1 reply; 12+ messages in thread From: Andrew Pinski @ 2002-10-21 23:00 UTC (permalink / raw) To: Ming Ouyang; +Cc: Dale Johannesen, gcc try this, using extensions for gcc: #define max(a,b) ({__typeof__(a) a1=(a); __typeof__(b) b1 = (b); (a>b)?a:b}) Thanks, Andrew Pinski On Monday, Oct 21, 2002, at 17:34 US/Pacific, Ming Ouyang wrote: > Dale, > 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. > > Ming > > --- Dale Johannesen <dalej@apple.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 >> like >> #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 > http://webhosting.yahoo.com/ > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: help on adding new insns like min/max 2002-10-21 23:00 ` Andrew Pinski @ 2002-10-21 23:27 ` Ming Ouyang 2002-10-21 23:30 ` Andrew Pinski 0 siblings, 1 reply; 12+ messages in thread From: Ming Ouyang @ 2002-10-21 23:27 UTC (permalink / raw) To: Andrew Pinski; +Cc: Dale Johannesen, gcc Andrew, Thanks for your reply. __typeof__ does make 2 or more min/max in one function work, but it can't resolve complicated operands problem yet, can you help on that? Thanks so much. Ming --- Andrew Pinski <apinski@apple.com> wrote: > try this, using extensions for gcc: > > #define max(a,b) ({__typeof__(a) a1=(a); __typeof__(b) b1 = (b); > (a>b)?a:b}) > > Thanks, > Andrew Pinski > > On Monday, Oct 21, 2002, at 17:34 US/Pacific, Ming Ouyang wrote: > > > Dale, > > 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. > > > > Ming > > > > --- Dale Johannesen <dalej@apple.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 > >> like > >> #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 > > http://webhosting.yahoo.com/ > > > __________________________________________________ Do you Yahoo!? Y! Web Hosting - Let the expert host your web site http://webhosting.yahoo.com/ ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: help on adding new insns like min/max 2002-10-21 23:27 ` Ming Ouyang @ 2002-10-21 23:30 ` Andrew Pinski 2002-10-21 23:31 ` Ming Ouyang 0 siblings, 1 reply; 12+ messages in thread From: Andrew Pinski @ 2002-10-21 23:30 UTC (permalink / raw) To: Ming Ouyang; +Cc: Dale Johannesen, gcc Actually I messed up the definition of max: #define max(a,b) ({__typeof__(a) a1=(a); __typeof__(b) b1 = (b); (a1>b1)?a1:b1}) Sorry, Andrew Pinski On Monday, Oct 21, 2002, at 18:03 US/Pacific, Ming Ouyang wrote: > Andrew, > Thanks for your reply. __typeof__ does make 2 or more min/max in one > function work, but it can't resolve complicated operands problem yet, > can you help on that? > Thanks so much. > > Ming > > > --- Andrew Pinski <apinski@apple.com> wrote: >> try this, using extensions for gcc: >> >> #define max(a,b) ({__typeof__(a) a1=(a); __typeof__(b) b1 = (b); >> (a>b)?a:b}) >> >> Thanks, >> Andrew Pinski >> >> On Monday, Oct 21, 2002, at 17:34 US/Pacific, Ming Ouyang wrote: >> >>> Dale, >>> 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. >>> >>> Ming >>> >>> --- Dale Johannesen <dalej@apple.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 >>>> like >>>> #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 >>> http://webhosting.yahoo.com/ >>> >> > > > __________________________________________________ > Do you Yahoo!? > Y! Web Hosting - Let the expert host your web site > http://webhosting.yahoo.com/ > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: help on adding new insns like min/max 2002-10-21 23:30 ` Andrew Pinski @ 2002-10-21 23:31 ` Ming Ouyang 0 siblings, 0 replies; 12+ messages in thread From: Ming Ouyang @ 2002-10-21 23:31 UTC (permalink / raw) To: Andrew Pinski; +Cc: Dale Johannesen, gcc I also found that just now :) Anyway, thank you very very much. Ming --- Andrew Pinski <apinski@apple.com> wrote: > Actually I messed up the definition of max: > > #define max(a,b) ({__typeof__(a) a1=(a); __typeof__(b) b1 = (b); > (a1>b1)?a1:b1}) > > Sorry, > Andrew Pinski > > > On Monday, Oct 21, 2002, at 18:03 US/Pacific, Ming Ouyang wrote: > > > Andrew, > > Thanks for your reply. __typeof__ does make 2 or more min/max in one > > function work, but it can't resolve complicated operands problem yet, > > can you help on that? > > Thanks so much. > > > > Ming > > > > > > --- Andrew Pinski <apinski@apple.com> wrote: > >> try this, using extensions for gcc: > >> > >> #define max(a,b) ({__typeof__(a) a1=(a); __typeof__(b) b1 = (b); > >> (a>b)?a:b}) > >> > >> Thanks, > >> Andrew Pinski > >> > >> On Monday, Oct 21, 2002, at 17:34 US/Pacific, Ming Ouyang wrote: > >> > >>> Dale, > >>> 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. > >>> > >>> Ming > >>> > >>> --- Dale Johannesen <dalej@apple.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 > >>>> like > >>>> #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 > >>> http://webhosting.yahoo.com/ > >>> > >> > > > > > > __________________________________________________ > > Do you Yahoo!? > > Y! Web Hosting - Let the expert host your web site > > http://webhosting.yahoo.com/ > > > __________________________________________________ Do you Yahoo!? Y! Web Hosting - Let the expert host your web site http://webhosting.yahoo.com/ ^ permalink raw reply [flat|nested] 12+ messages in thread
* help on adding new insns like min/max @ 2002-10-21 16:22 Ming Ouyang 2002-10-21 16:22 ` Dale Johannesen 2002-10-21 16:31 ` Jan Hubicka 0 siblings, 2 replies; 12+ messages in thread From: Ming Ouyang @ 2002-10-21 16:22 UTC (permalink / raw) To: gcc Hi everyone, I need to add new insns support to our gcc 3.0 to support min and max insns, but it seems that I can't describe such function-level insns on RTL level, probably I need to change something in c-common.c or something like it? Does anyone have any idea on that? Thanks a lot. Ming __________________________________________________ Do you Yahoo!? Y! Web Hosting - Let the expert host your web site http://webhosting.yahoo.com/ ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: help on adding new insns like min/max 2002-10-21 16:22 Ming Ouyang @ 2002-10-21 16:22 ` Dale Johannesen 2002-10-21 17:11 ` Ming Ouyang 2002-10-21 16:31 ` Jan Hubicka 1 sibling, 1 reply; 12+ messages in thread From: Dale Johannesen @ 2002-10-21 16:22 UTC (permalink / raw) To: Ming Ouyang; +Cc: Dale Johannesen, gcc On Monday, October 21, 2002, at 03:07 PM, Ming Ouyang wrote: > Hi everyone, > > I need to add new insns support to our gcc 3.0 to support min > and max insns, but it seems that I can't describe such function-level > insns on RTL level, probably I need to change something in c-common.c > or something like it? The patterns smin<type>, umin<type>, smax<type>, umax<type> are supported in RTL. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: help on adding new insns like min/max 2002-10-21 16:22 ` Dale Johannesen @ 2002-10-21 17:11 ` Ming Ouyang 0 siblings, 0 replies; 12+ messages in thread From: Ming Ouyang @ 2002-10-21 17:11 UTC (permalink / raw) To: gcc Dale, Thanks for your reply, but I wonder how gcc will handle code like: c = min(a, b) Does min/max will be treated as builtins? Or can you demonstrate how to make gcc to use sminsi3/smaxsi3... to use min/max insns for code like that? Thanks a lot. Ming --- Dale Johannesen <dalej@apple.com> wrote: > > On Monday, October 21, 2002, at 03:07 PM, Ming Ouyang wrote: > > > Hi everyone, > > > > I need to add new insns support to our gcc 3.0 to support min > > and max insns, but it seems that I can't describe such function-level > > insns on RTL level, probably I need to change something in c-common.c > > or something like it? > > The patterns smin<type>, umin<type>, smax<type>, umax<type> are > supported > in RTL. > __________________________________________________ Do you Yahoo!? Y! Web Hosting - Let the expert host your web site http://webhosting.yahoo.com/ ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: help on adding new insns like min/max 2002-10-21 16:22 Ming Ouyang 2002-10-21 16:22 ` Dale Johannesen @ 2002-10-21 16:31 ` Jan Hubicka 1 sibling, 0 replies; 12+ messages in thread From: Jan Hubicka @ 2002-10-21 16:31 UTC (permalink / raw) To: Ming Ouyang; +Cc: gcc > Hi everyone, > > I need to add new insns support to our gcc 3.0 to support min > and max insns, but it seems that I can't describe such function-level The min and max instructions can be discovered by GCC automatically from "C" alternatives in if conversion pass. Alternatively you can add new builtins for that, but that needs gcc 3.1 do be done cleanly I believe. Honza > insns on RTL level, probably I need to change something in c-common.c > or something like it? > > Does anyone have any idea on that? Thanks a lot. > > Ming > > > __________________________________________________ > Do you Yahoo!? > Y! Web Hosting - Let the expert host your web site > http://webhosting.yahoo.com/ ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2002-10-22 1:17 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <441B9D0E-E548-11D6-8BE6-000393D76DAA@apple.com> 2002-10-21 17:39 ` help on adding new insns like min/max Ming Ouyang 2002-10-21 18:02 ` Dale Johannesen 2002-10-21 18:21 ` Ming Ouyang 2002-10-21 20:42 ` Ming Ouyang 2002-10-21 23:00 ` Andrew Pinski 2002-10-21 23:27 ` Ming Ouyang 2002-10-21 23:30 ` Andrew Pinski 2002-10-21 23:31 ` Ming Ouyang 2002-10-21 16:22 Ming Ouyang 2002-10-21 16:22 ` Dale Johannesen 2002-10-21 17:11 ` Ming Ouyang 2002-10-21 16:31 ` Jan Hubicka
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).