Hello. Looking at machine description of functions like ceil/floor and I think specifically:
(define_expand "<rounding_insn><mode>2" Roundeven should be described as define_expand (or within this alongside ceil and floor?) with expand functions to emit instructions in i386-builtins.c? Referring to <www.info.univ-angers.fr/pub/richer/ens/l3info/ao/intel_sse4.pdf>, operands of these instructions work with xmm registers, memory and imm8 for rounding mode. > existing ROUND_NO_EXC definition in GCC. A new definition will need > adding alongside ROUND_FLOOR, ROUND_CEIL and ROUND_TRUNC to correspond to > rounding to nearest with ties to even, evaluating to 0.) So (ROUND_ROUNDEVEN 0x0) be declared for rounding towards nearest even for rounding mode argument? But reference says that RC field should end up as 00B for rounding ties to even? I am also much confused about machine-type flags used as C conditions. How do we determine which ones to check and does it depends on exceptions and conditions described in the reference? Also, do ROUNDEVEN needs to be defined as (how): (define_int_attr rounding_insn [(UNSPEC_FRNDINT_FLOOR "floor") Thanks, --Tejas On Fri, 14 Jun 2019 at 23:02, Martin Jambor <mjam...@suse.cz> wrote: > > Hi, > > On Fri, Jun 14 2019, Tejas Joshi wrote: > >> Of course the instruction is not present there, that is the next step in > >> your project :-) > > > > Yes, of course, but what I meant was that instructions for existing > > round/ceil functions and not roundeven. If inlining for these > > functions is available, how can I inspect such instructions getting > > inlined maybe in a *.s file? > > Make sure you compile to a target that has the rounding instruction, > i.e. by using an appropriate -march or -mavx) and also specify > -ffast-math on the command line. I have not double checked, but I > assume the latter is necessary (mainly) because it implies > -fno-math-errno and most of the math builtin expansion into instructions > is guarded by check for !flag_errno_math. > > So e.g. my test input: > > double > callplusone (double d) > { > return __builtin_round (d) + 1; > } > > has vroundsd instruction in the output of: > > ~/gcc/trunk/inst/bin/gcc -O2 -S expand_example.c -mavx -ffast-math > > > > > Also, I am trying to find appropriate places to introduce changes for > > roundeven to be inlined. Attached patch is what I have tried so far to > > find the places. > > So far I only quickly glanced over it but it seems to be going in the > right direction. I'll try to answer the rest of your questions as soon > as I can but I also have to look a bit into the machine descriptions > myself first. > > Martin > > > > ix86_expand_roundeven have dummy code for the sake of time. > > > > In i386.md: > > 1. How should roundeven be defined at certain places where existing > > floor is defined as: > > (define_int_attr rounding_insn > > [(UNSPEC_FRNDINT_FLOOR "floor") > > > > 2. Also, can roundeven be handled like round_floor is handled by: > > (define_expand "<rounding_insn><mode>2" > > but definitely with certain changes of flags, options and macros. > > > > Thanks, > > --Tejas