]> granicus.if.org Git - llvm/commitdiff
[Intrinsics] Merge lround.i32 and lround.i64 into a single intrinsic with overloaded...
authorCraig Topper <craig.topper@intel.com>
Mon, 20 May 2019 16:27:09 +0000 (16:27 +0000)
committerCraig Topper <craig.topper@intel.com>
Mon, 20 May 2019 16:27:09 +0000 (16:27 +0000)
We shouldn't really make assumptions about possible sizes for long and long long. And longer term we should probably support vectorizing these intrinsics. By making the result types not fixed we can support vectors as well.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361169 91177308-0d34-0410-b5e6-96231b3b80d8

docs/LangRef.rst
include/llvm/IR/Intrinsics.td
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
lib/IR/Verifier.cpp

index 07d755c1d788c85b91c00f3de4dc8dd2752e4202..3f35752b450fdda2272b6c9161681fb38f42e5b8 100644 (file)
@@ -12398,8 +12398,7 @@ nearest integer.
 Arguments:
 """"""""""
 
-The argument is a floating-point number and return is i32 for
-``llvm.lround.i32`` and i64 for ``llvm.lround.i64``.
+The argument is a floating-point number and return is an integer type.
 
 Semantics:
 """"""""""
@@ -12418,11 +12417,11 @@ floating-point type. Not all targets support all types however.
 
 ::
 
-      declare i64 @llvm.lround.f32(float %Val)
-      declare i64 @llvm.lround.f64(double %Val)
-      declare i64 @llvm.lround.f80(float %Val)
-      declare i64 @llvm.lround.f128(double %Val)
-      declare i64 @llvm.lround.ppcf128(double %Val)
+      declare i64 @llvm.lround.i64.f32(float %Val)
+      declare i64 @llvm.lround.i64.f64(double %Val)
+      declare i64 @llvm.lround.i64.f80(float %Val)
+      declare i64 @llvm.lround.i64.f128(double %Val)
+      declare i64 @llvm.lround.i64.ppcf128(double %Val)
 
 Overview:
 """""""""
@@ -12433,7 +12432,7 @@ nearest integer.
 Arguments:
 """"""""""
 
-The argument is a floating-point number and return is i64.
+The argument is a floating-point number and return is an integer type.
 
 Semantics:
 """"""""""
index a1e37b66c5fa2a1d960b4c728b19d894c871d21d..2957478ef5baa795e223b3c83f400d4400fef57f 100644 (file)
@@ -539,9 +539,8 @@ let IntrProperties = [IntrNoMem, IntrSpeculatable] in {
   def int_canonicalize : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>],
                                    [IntrNoMem]>;
 
-  def int_lround_i32 : Intrinsic<[llvm_i32_ty], [llvm_anyfloat_ty]>;
-  def int_lround_i64 : Intrinsic<[llvm_i64_ty], [llvm_anyfloat_ty]>;
-  def int_llround    : Intrinsic<[llvm_i64_ty], [llvm_anyfloat_ty]>;
+  def int_lround : Intrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
+  def int_llround : Intrinsic<[llvm_anyint_ty], [llvm_anyfloat_ty]>;
 }
 
 def int_minnum : Intrinsic<[llvm_anyfloat_ty],
index 938aeafb435457b7ddbdc3a6417cb19265f0d705..339800400517677306de76224c4754694fe76a49 100644 (file)
@@ -6034,18 +6034,16 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
                              getValue(I.getArgOperand(0))));
     return;
   }
-  case Intrinsic::lround_i32:
-  case Intrinsic::lround_i64:
+  case Intrinsic::lround:
   case Intrinsic::llround: {
     unsigned Opcode;
-    MVT RetVT;
     switch (Intrinsic) {
     default: llvm_unreachable("Impossible intrinsic");  // Can't reach here.
-    case Intrinsic::lround_i32: Opcode = ISD::LROUND;  RetVT = MVT::i32; break;
-    case Intrinsic::lround_i64: Opcode = ISD::LROUND;  RetVT = MVT::i64; break;
-    case Intrinsic::llround:    Opcode = ISD::LLROUND; RetVT = MVT::i64; break;
+    case Intrinsic::lround:  Opcode = ISD::LROUND;  break;
+    case Intrinsic::llround: Opcode = ISD::LLROUND; break;
     }
 
+    EVT RetVT = TLI.getValueType(DAG.getDataLayout(), I.getType());
     setValue(&I, DAG.getNode(Opcode, sdl, RetVT,
                              getValue(I.getArgOperand(0))));
     return;
index f7004cf4eae605dd8e2fb99e63b48c296886761f..67d43ce77402a49b006323f9f996389ef8d33bce 100644 (file)
@@ -4620,6 +4620,14 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
     }
     break;
   }
+  case Intrinsic::lround:
+  case Intrinsic::llround: {
+    Type *ValTy = Call.getArgOperand(0)->getType();
+    Type *ResultTy = Call.getType();
+    Assert(!ValTy->isVectorTy() && !ResultTy->isVectorTy(),
+           "Intrinsic does not support vectors", &Call);
+    break;
+  }
   };
 }