https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92488
Bug ID: 92488
Summary: GCC generates to calls to __dpd_trunctdsd2 with
-mhard-dfp
Product: gcc
Version: 9.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: murphyp at linux dot vnet.ibm.com
Target Milestone: ---
While cleaning up libdfp, I noticed GCC still leans on libgcc to perform
_Decimal128 to _Decimal32 truncation.
This can be inlined with 4-5 instructions depending on ISA using the "round to
prepare for shorter precision" rounding mode supported on all PPC DFP targets:
mffs fp4 /* Save current rounding mode. */
mtfsfi 7, 7, 1 /* Set round to prepare for shorter. */
drdpq fp0,fp2 /* Initial round to _Decimal64. */
mtfsf 0xff,fp4,1,0 /* Restore previous rounding mode. */
drsp fp1,fp0 /* Round result to _Decimal32. */
mffs/mtsfi could be substituted for "mffscdrni fp4, 7" on ISA 3.0 and above.
e.g the following trivial example:
_Decimal32
truncd128(_Decimal128 d)
{
return d;
}