[PATCH, i386]: Rewrite x87 sqrt patterns, take 2 (macroized)

Uros Bizjak ubizjak@gmail.com
Thu Nov 23 11:28:00 GMT 2006


> Attached patch introduces new insn patterns that implements no-op
> truncation via UNSPEC. UNSPEC implementation is necessary in order to
> prevent any optimization to simplify real reg->mem->reg x87 truncation
> into a no-op, and to distinguish it from -ffast-math no-op truncation
> (it is expected that -ffast-math optimizes to as many no-op truncations
> as possible in x87 case).
> The asm code, generated for the fsqrt testcase in my previous post is
> now the same as without patch. In addition, fmod patterns were changed
> to use no-op truncation, to be consistent with sqrt expanders.
> Patch was bootstrapped on x86_64-linux-gnu, regression test is in
> progress. OK for mainline if it passes?

The patch was also bootstrapped and regression tested on
i686-pc-linux-gnu for c,c++ and fortran. Povray-3.6.1 was also built,
where patched gcc reduces text size for ~300bytes from 1077055 to
1076719. To my suprise, povray is ~0.5% faster when built with patched

I took this patch a bit further and implement all sqrt patterns using
macros. This revision is attached to the message. It was re-tested on

OK for mainline?

2006-11-23  Uros Bizjak  <ubizjak@gmail.com>

	config/i386/i386.md (UNSPEC_TRUNC_NOOP): New unspec definition.
	(X87MODEF): New mode macro.
	(ssemodefsuffix): New mode attribute.
	(truncxf<mode>2_i387_noop_unspec): New insn pattern.
	(sqrt<mode>2): For non-SSE sqrt, extend operand 1 to XFmode,
	emit sqrtxf2 insn and truncate result back to original mode
	using UNSPEC_TRUNC_NOOP truncation.
	(*sqrt<mode>2_sse): Implement using SSEMODEF mode macro and
	ssemodefsuffix mode attribute.
	(*sqrtsf2_mixed, *sqrtsf2_i387, *sqrtdf2_mixed, *sqrtdf2_i387)
	(*sqrtextendsfdf2_i387, *sqrtextendsfxf2_i387)
	(*sqrtextenddfxf2_i387): Remove insn patterns.

	(fmodsf3, fmoddf3, remaindersf3, remainderdf3): Use noop
	truncation patterns.

	reg-stack.c (get_true_reg): Handle UNSPEC_TRUNC_NOOP.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: i386-sqrt-3.diff
Type: application/octet-stream
Size: 8367 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20061123/1703ae37/attachment.obj>

More information about the Gcc-patches mailing list