On Wed, Sep 7, 2011 at 10:01 PM, Jakub Jelinek <ja...@redhat.com> wrote: > On Wed, Sep 07, 2011 at 09:54:03PM +0200, Uros Bizjak wrote: >> > 2011-09-07 Jakub Jelinek <ja...@redhat.com> >> > >> > PR target/50310 >> > * config/i386/i386.c (ix86_prepare_sse_fp_compare_args): For >> > TARGET_AVX return code for LTGT and UNEQ. >> > (ix86_expand_fp_vcond): Handle LTGT and UNEQ. >> > >> > * gcc.c-torture/execute/ieee/pr50310.c: New test. >> > * gcc.dg/pr50310-2.c: New test. >> >> Please put early exit for TARGET_SSE at the beginning of >> ix86_prepare_sse_fp_compare_args function. There is really no need to > > You mean for TARGET_AVX, right? > >> swap operands - and to help reload, since AVX instructions are >> three-operand instructions. >> >> OK for mainline with this change. > > Here is the updated patch, I'll bootstrap/regtest it now. > > 2011-09-07 Jakub Jelinek <ja...@redhat.com> > > PR target/50310 > * config/i386/i386.c (ix86_prepare_sse_fp_compare_args): Return > code early if TARGET_AVX. > (ix86_expand_fp_vcond): Handle LTGT and UNEQ. > > * gcc.c-torture/execute/ieee/pr50310.c: New test. > * gcc.dg/pr50310-2.c: New test. > > --- gcc/config/i386/i386.c.jj 2011-09-02 16:29:38.000000000 +0200 > +++ gcc/config/i386/i386.c 2011-09-07 21:57:52.000000000 +0200 > @@ -18304,6 +18304,11 @@ ix86_prepare_sse_fp_compare_args (rtx de > { > rtx tmp; > > + /* AVX supports all the needed comparisons, no need to swap arguments > + nor help reload. */ > + if (TARGET_AVX) > + return code; > +
Unfortunately, this part prevents generation of vmin/vmax instructions for TARGET_AVX. In ix86_expand_fp_movcc, we call ix86_prepare_sse_fp_compare_args, where we previously converted GT into LT. LT is recognized in ix86_expand_sse_fp_minmax as valid operand for MIN/MAX, whereas GT is not. I'm not sure if we can swap operands in ix86_expand_sse_fp_minmax, there is a scary comment in front of ix86_expand_sse_fp_minmax w.r.t. to IEEE safety. The test is gcc.target/i386/ssefp-?.c, please compile it with "-O2 -mavx". Uros.