Similar to the avg_floor, the avg_ceil has the rounding mode
towards +inf, while the vaadd.vv has the rnu which totally match
the sematics.  From RVV spec, the fixed vaadd.vv with rnu,

The CI shows some scan failures in vls/avg-[456].c and widen/vec-avg-rv32gcv.c.

Also, the lint check complains about this line:
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP_VXRM_RNU, 
operands);
being to long.

OK with those two fixed, thanks.

For the record.  When I first introduced these patterns I wasn't really
aware of VXRM's properties, i.e. that we can just set it before a loop without restoring it. Therefore I implemented it using regular vector ops.

Juzhe's patch used vaaddu for the unsigned variants but left the signed
ones as is. I believe that was due to concerns about the general averaging idiom for signed integers (where we need to round towards zero), but not the
special avg_ceil and avg_floor touched here.  The latter ones are a good match
for vaadd, the general case is not.

--
Regards
Robin

Reply via email to