[PATCH] D79830: Add support of __builtin_expect_with_probability

Zhi Zhuang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 12 17:48:24 PDT 2020


LukeZhuang created this revision.
LukeZhuang added reviewers: RKSimon, phosek, gribozavr, davidxl, chandlerc, pete, jyknight, dblaikie, kuba.
LukeZhuang added projects: LLVM, clang.
Herald added subscribers: llvm-commits, cfe-commits, jdoerfert, hiraditya.

Add a new builtin-function `__builtin_expect_with_probability` and intrinsic `llvm.expect.with.probability`.
The interface is `__builtin_expect_with_probability(long expr, long expected, double probability)`.
It is mainly the same as `__builtin_expect` besides one more argument indicating the probability of expression equal to expected value. The probability should be a constant floating-point expression and be in range [0.0, 1.0] inclusive.
It is similar to builtin-expect-with-probability function in GCC built-in functions <https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79830

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtin-expect-with-probability-switch.c
  clang/test/CodeGen/builtin-expect-with-probability.c
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79830.263566.patch
Type: text/x-patch
Size: 9832 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200513/c35081c2/attachment-0001.bin>


More information about the llvm-commits mailing list