[PATCH] D18643: Mark llvm.round.* and llvm.rint.* intrinsics as safe to speculatively execute

whitequark via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 31 06:06:37 PDT 2016


whitequark created this revision.
whitequark added a subscriber: llvm-commits.
whitequark set the repository for this revision to rL LLVM.

Floating point intrinsics in LLVM are generally not speculatively executed,
since most of them are defined to behave the same as libm functions, which set errno.
However, the only error that can happen when executing round and rint per POSIX.1-2001
is -ERANGE, and that requires the maximum value of the exponent to be smaller than
the number of mantissa bits, which is not the case with any of the floating point types
supported by LLVM.

Repository:
  rL LLVM

http://reviews.llvm.org/D18643

Files:
  lib/Analysis/ValueTracking.cpp

Index: lib/Analysis/ValueTracking.cpp
===================================================================
--- lib/Analysis/ValueTracking.cpp
+++ lib/Analysis/ValueTracking.cpp
@@ -3126,6 +3126,12 @@
       case Intrinsic::minnum:
       case Intrinsic::maxnum:
         return true;
+      // These intrinsics are defined to have the same behavior as libm
+      // functions, which never overflow when operating on the IEEE754 types
+      // that we support.
+      case Intrinsic::round:
+      case Intrinsic::rint:
+        return true;
       // TODO: some fp intrinsics are marked as having the same error handling
       // as libm. They're safe to speculate when they won't error.
       // TODO: are convert_{from,to}_fp16 safe?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18643.52193.patch
Type: text/x-patch
Size: 739 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160331/31390096/attachment.bin>


More information about the llvm-commits mailing list