This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH, i386]: Rewrite x87 sqrt patterns, take 2a (macroized)
- From: Uros Bizjak <ubizjak at gmail dot com>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: Michael Matz <matz at suse dot de>, Andrew Haley <aph at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 25 Nov 2006 10:17:55 +0100
- Subject: Re: [PATCH, i386]: Rewrite x87 sqrt patterns, take 2a (macroized)
- References: <Pine.LNX.firstname.lastname@example.org>
Roger Sayle wrote:
Hi Uros,This part of reg-stack.c change to get_true_reg() lowers
UNSPEC_TRUNC_NOOP to plain move:
On Fri, 24 Nov 2006, Uros Bizjak wrote:
2006-11-24 Uros Bizjak <email@example.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_extend<mode>xf2_i387): New insn pattern.
(sqrt<mode>2): For non-SSE sqrt, emit sqrt_extend<mode>xf2_i387
insn and truncate result back to original mode using
(*sqrt<mode>2_sse): Implement using SSEMODEF mode macro and
ssemodefsuffix mode attribute.
(*sqrtsf2_mixed, *sqrtsf2_i387, *sqrtdf2_mixed, *sqrtdf2_i387)
(*sqrtextenddfxf2_i387): Remove insn patterns.
(fmodsf3, fmoddf3, remaindersf3, remainderdf3): Use noop
reg-stack.c (get_true_reg): Handle UNSPEC_TRUNC_NOOP.
This patch looks like a step in the right direction. Ok for mainline.
However my brain isn't working at the moment, so I'm unsure whether and
how the UNSPEC_TRUNC_NOOP gets optimized away with -ffast-math. For
+ case UNSPEC:
+ if (XINT (*pat, 1) == UNSPEC_TRUNC_NOOP)
+ pat = & XVECEXP (*pat, 0, 0);
When operands == operands, the move itself is removed, and at this
point the optimization you described below takes place.
(During the discussion, it was agreed that builtins can extend returned
value to XFmode without truncating the value back to its original mode,
as the user can use -ffloat store in this case or -fno-builtin-XX).
example, i386.c's output_387_reg_move doesn't appear to do anything
clever when operands == operands. However even without
understanding exactly what's going on, I agree with the philosophy
of making the XFmode operations more explicit and using macros to
simplify the backends patterns, and I trust you enough that your
implementation is sound. I can figure out how things work once its
in the tree.
Roger, thanks for your review!