https://bugs.llvm.org/show_bug.cgi?id=36617

            Bug ID: 36617
           Summary: Missing float truncation rounding patterns
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedb...@nondot.org
          Reporter: llvm-...@redking.me.uk
                CC: efrie...@codeaurora.org, hfin...@anl.gov,
                    llvm-bugs@lists.llvm.org, sca...@apple.com,
                    spatel+l...@rotateright.com

Rounding floats/doubles patterns could be converted to truncation rounding
instructions (roundss on x86/sse etc.). AFAICT these don't need to be
-ffast-math only.

float rnd(float x) {
  return (float)((int)x);
}
__v4sf rnd(__v4sf x) {
    return __builtin_convertvector(__builtin_convertvector(x, __v4si), __v4sf);
}

define dso_local float @_Z3rndf {
  %2 = fptosi float %0 to i32
  %3 = sitofp i32 %2 to float
  ret float %3
}
define dso_local <4 x float> @_Z3rndDv4_f {
  %2 = fptosi <4 x float> %0 to <4 x i32>
  %3 = sitofp <4 x i32> %2 to <4 x float>
  ret <4 x float> %3
}

_Z3rndf:
  cvttss2si %xmm0, %eax
  xorps %xmm0, %xmm0
  cvtsi2ssl %eax, %xmm0
  retq
_Z3rndDv4_f:
  cvttps2dq %xmm0, %xmm0
  cvtdq2ps %xmm0, %xmm0
  retq

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to