[llvm-commits] Bug fix in double-to-int conversions codegen in AVX: please review

Eli Friedman eli.friedman at gmail.com
Wed Jan 25 11:32:35 PST 2012


On Wed, Jan 25, 2012 at 2:19 AM, Umansky, Victor
<victor.umansky at intel.com> wrote:
> Hi
>
> The attached patch file includes a fix for the following bug in AVX codegen
> for double-to-int conversions:
>
> "fptosi" and "fptoui" IR instructions are defined with round-to-zero
> rounding mode.
> Currently for AVX mode for <4xdouble> and <8xdouble>  the "VCVTPD2DQ.128"
> and "VCVTPD2DQ.256" instructions are selected (for “fp_to_sint” DAG node
> operation ) by AVX codegen. However they use round-to-nearest-even rounding
> mode.
> Consequently, the conversion produces incorrect numbers.
>
>
> The fix is to replace selection of VCVTPD2DQ instructions with VCVTTPD2DQ
> instructions. The latter use truncate (i.e. round-to-zero) rounding mode.
> As “fp_to_sint” DAG node operation is used only for lowering of  "fptosi"
> and "fptoui" IR instructions, the fix in X86InstrSSE.td definition file
> doesn’t have an impact on other LLVM flows.
>
> The patch includes changes in the .td file, LIT test for the changes and a
> fix in a legacy LIT test (which produced asm code conflicting with LLVN IR
> spec).
>
> I’d like to commit the fix to the LLVM trunk, and your feedback will be
> mostly appreciated.

--- test/CodeGen/X86/avx-fp2int.ll	(revision 0)
+++ test/CodeGen/X86/avx-fp2int.ll	(revision 0)
@@ -0,0 +1,19 @@
+;; Check that FP_TO_SINT and FP_TO_INT generate convert with truncate
+
+; RUN: llc < %s -mtriple=i386-apple-darwin10 -mcpu=corei7-avx
-mattr=+avx | FileCheck %s

I assume you mean FP_TO_UINT?  Also, please make the RUN-line the
first line of the file.

Otherwise, patch looks good; please commit.

-Eli




More information about the llvm-commits mailing list