This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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 gcc.

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 <>

	config/i386/ (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.


Attachment: i386-sqrt-3.diff
Description: Binary data

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]