[GSoC-19] Expanding Roundeven

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GSoC-19] Expanding Roundeven

Tejas Joshi
Hello.
This was a mail in thread  Re: Expanding roundeven on 19th June but as
its gone far inside the thread, I thought of having a fresh one. The
following patch expands roundeven with instruction vroundsd using
-mavx option but without it is giving internal compiler error which I
believe is due to reaching gcc_unreachable (). The doubts I had come
up with :
Test code compiled with attached patch:

double
plusone (double d)
{
    return __builtin_roundeven (d) + 1;
}

Compiling the program using -O2 gave internal compiler error which
I believe is because gcc_unreachable() at:

Inside :
(define_expand "<rounding_insn><mode>2"

There is a condition :

if (TARGET_SSE4_1)
    emit_insn (gen_sse4_1_round<mode>2
           (operands[0], operands[1], GEN_INT (ROUND_<ROUNDING>
                               | ROUND_NO_EXC)));

I think the above condition matches the criterion which Joseph
previously mentioned? :
> I think the code will be much clearer if it explicitly says
> ROUND_ROUNDEVEN | ROUND_NO_EXC,

     else if (TARGET_64BIT || (<MODE>mode != DFmode))
    {
      if (ROUND_<ROUNDING> == ROUND_FLOOR)
        ix86_expand_floorceil (operands[0], operands[1], true);
      else if (ROUND_<ROUNDING> == ROUND_CEIL)
        ix86_expand_floorceil (operands[0], operands[1], false);
      else if (ROUND_<ROUNDING> == ROUND_TRUNC)
        ix86_expand_trunc (operands[0], operands[1]);
      else
        gcc_unreachable ();
    }

But with -mavx option, assembly generated the vroundsd insn. Does it
mean ROUNDEVEN
should have a condition in the above else if, but comments above
ix86_expand* functions in i386-expand.c says that those are for SSE2
sequences?

Thanks,
-Tejas

roundeven-md1.patch (7K) Download Attachment