[NVPTX] Fix the codegen for llvm.round.
authorBixia Zheng <bixia@google.com>
Mon, 1 Apr 2019 16:10:26 +0000 (16:10 +0000)
committerBixia Zheng <bixia@google.com>
Mon, 1 Apr 2019 16:10:26 +0000 (16:10 +0000)
commit6c21ccd245bb89134a296a5ccf74ef2a5158f6e9
treed5eb8005ed824f63634b2c20bb5f45657749181e
parentd109e2a7c3b7602c92e1fd92884876a28b68fd78
[NVPTX] Fix the codegen for llvm.round.

Summary:
Previously, we translate llvm.round to PTX cvt.rni, which rounds to the
even interger when the source is equidistant between two integers. This
is not correct as llvm.round should round away from zero. This change
replaces llvm.round with a round away from zero implementation through
target specific custom lowering.

Modify a few affected tests to not check for cvt.rni. Instead, we check
for the use of a few constants used in implementing round. We are also
adding CUDA runnable tests to check for the values produced by
llvm.round to test-suites/External/CUDA.

Reviewers: tra

Subscribers: jholewinski, sanjoy, jlebar, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D59947

llvm-svn: 357407
llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
llvm/lib/Target/NVPTX/NVPTXISelLowering.h
llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
llvm/test/CodeGen/NVPTX/f16-instructions.ll
llvm/test/CodeGen/NVPTX/f16x2-instructions.ll
llvm/test/CodeGen/NVPTX/math-intrins.ll