This is the mail archive of the gcc-patches@gcc.gnu.org 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]

Re: [PATCH, i386] Unify TARGET_SSE_MATH for trunc* patterns


On Fri, Dec 17, 2004 at 11:39:40AM +0100, Uros Bizjak wrote:
> -(define_insn "*truncdfsf2_1_sse"
> +(define_insn "*truncdfsf2_2"
...
> -(define_insn "*truncdfsf2_1_sse_nooverlap"
> +(define_insn "*truncdfsf2_2_nooverlap"
...
> -(define_insn "*truncdfsf2_2"
> +(define_insn "*truncdfsf2_mixed"

Missed truncdfsf2_1?  You're not ordering these as we discussed,
and you had been doing for the other patches.  Which makes me 
doubt we'll select the proper pattern.

I'm a bit confused about the choices here in the trunc patterns
in general.  We have choices:

(1) -ffast-math.
(2) allow 80387 reg-reg, but require a scratch memory,
(3) disallow 80387 reg-reg, no scratch memory.

However, the patterns are not consistent in their selection of
2 or 3, and don't seem to allow for all alternatives allowed by
-mfpmath.

As an aside, I would support removing TARGET_SSE_PARTIAL_REGS_FOR_CVTSD2SS,
since it's currently always zero.  Honza, is this the remnants of
of an experiment to see what's faster, or is this supposed to be
set for Athlon, or what?

It seems like we can merge cases (1) and (3).  Which would result
in something like this:


(define_expand "truncdfsf2"
  [(set (match_operand:SF 0 "nonimmediate_operand" "")
	(float_truncate:SF
	  (match_operand:DF 1 "nonimmediate_operand" "")))]
  "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
{
  if (MEM_P (operands[0]) && MEM_P (operands[1]))
    operands[1] = force_reg (DFmode, operands[1]);

  if (TARGET_SSE2 && TARGET_SSE_MATH && !TARGET_MIX_SSE_I387)
    ;
  else if (flag_unsafe_math_optimizations)
    ;
  else
    {
      emit_insn (gen_truncdfsf2_with_temp (operands[0], operands[1], 
					   assign_386_stack_local (SFmode, 0)));
      DONE;
    }
})

(define_expand "truncdfsf2_with_temp"
  [(parallel [(set (match_operand:SF 0 "" "")
		   (float_truncate:SF (match_operand:DF 1 "" "")))
	      (clobber (match_operand:SF 2 "" ""))])]
  "")

(define_insn "*truncdfsf_fast_mixed"
  [(set (match_operand:SF 0 "nonimmediate_operand"   "=m,f,Y")
        (float_truncate:SF
          (match_operand:DF 1 "nonimmediate_operand" "f ,f,Ym")]
  "TARGET_SSE2 && TARGET_MIX_SSE_I387 && flag_unsafe_math_optimizations"
  ...)

;; Yes, this one doesn't depend on flag_unsafe_math_optimizations,
;; because nothing we do here is unsafe.
(define_insn "*truncdfsf_fast_sse"
  [(set (match_operand:SF 0 "nonimmediate_operand"   "=Y")
        (float_truncate:SF
          (match_operand:DF 1 "nonimmediate_operand" "Ym")]
  "TARGET_SSE2 && TARGET_SSE_MATH"
  ...)

(define_insn "*truncdfsf_fast_i387"
  [(set (match_operand:SF 0 "nonimmediate_operand"   "=fm")
        (float_truncate:SF
          (match_operand:DF 1 "nonimmediate_operand" "f")]
  "TARGET_80387 && flag_unsafe_math_optimizations"
  ...)

(define_insn "*truncdfsf_mixed"
  [(set (match_operand:SF 0 "nonimmediate_operand"   "=m,f,?fx*r,Y")
	(float_truncate:SF
	  (match_operand:DF 1 "nonimmediate_operand" "f ,f,f    ,Ym")
   (clobber (match_operand:SF 2 "memory_operand"     "X ,m,m    ,X"))]
  "TARGET_SSE2 && TARGET_MIX_SSE_I387"
  ...)

(define_insn "*truncdfsf_i387"
  [(set (match_operand:SF 0 "nonimmediate_operand"   "=m,f,?fx*r")
	(float_truncate:SF
	  (match_operand:DF 1 "nonimmediate_operand" "f ,f,f    ")
   (clobber (match_operand:SF 2 "memory_operand"     "X ,m,m    "))]
  "TARGET_80387"
  ...)

(splitters go here)



r~


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