https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110007
Bug ID: 110007 Summary: Implement support for Clang’s __builtin_unpredictable() Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: richard.yao at alumni dot stonybrook.edu Target Milestone: --- Having the ability to specify __builtin_unpredictable() as a hint to encourage the compiler to use cmov would be useful for implementing algorithms like binary search that have unpredictable branches. __builtin_expect_with_probability() looks like a possible substitute, but Clang does not support it and it does not always work as described in #110001. Combining this with C’s ternary operator should make the proposed cmov builtin from #98801 unnecessary. Note that while clang implements __builtin_unpredictable(), it does not currently pass that information to the backend: https://github.com/llvm/llvm-project/issues/62790#issuecomment-1552671099