[GlobalISel] Translate @llvm.llround.* -> G_LLROUND
authorJessica Paquette <jpaquette@apple.com>
Mon, 23 Aug 2021 16:16:20 +0000 (09:16 -0700)
committerJessica Paquette <jpaquette@apple.com>
Mon, 23 Aug 2021 16:42:53 +0000 (09:42 -0700)
Translate it using `IRTranslator::translateSimpleIntrinsic`.

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

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll

index b60b1d3..989caa4 100644 (file)
@@ -1765,6 +1765,8 @@ unsigned IRTranslator::getSimpleIntrinsicOpcode(Intrinsic::ID ID) {
       return TargetOpcode::G_VECREDUCE_UMIN;
     case Intrinsic::lround:
       return TargetOpcode::G_LROUND;
+    case Intrinsic::llround:
+      return TargetOpcode::G_LLROUND;
   }
   return Intrinsic::not_intrinsic;
 }
index 3bf7a5c..7d77f87 100644 (file)
@@ -2470,3 +2470,16 @@ define i64 @lround(float %x) {
   %lround = tail call i64 @llvm.lround.i64.f32(float %x)
   ret i64 %lround
 }
+
+declare i64 @llvm.llround.i64.f32(float) nounwind readnone
+define i64 @llround(float %x) {
+  ; CHECK-LABEL: name: llround
+  ; CHECK: bb.1 (%ir-block.0):
+  ; CHECK:   liveins: $s0
+  ; CHECK:   [[COPY:%[0-9]+]]:_(s32) = COPY $s0
+  ; CHECK:   [[LLROUND:%[0-9]+]]:_(s64) = G_LLROUND [[COPY]](s32)
+  ; CHECK:   $x0 = COPY [[LLROUND]](s64)
+  ; CHECK:   RET_ReallyLR implicit $x0
+  %lround = tail call i64 @llvm.llround.i64.f32(float %x)
+  ret i64 %lround
+}