llvm / llvm/llvm-project

[clang] Add `__builtin_fmaximum` which lowers to `llvm.maximum`

Open
#171,263 3 comments 0 reactions 0 assignees View on GitHub
clang:codegen clang:frontend floating-point
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

This is a feature request.

Currently, there exists a `__builtin_fmax` and a `__builtin_fmaximum_num` to implement the corresponding `` functions, but there exists no `__builtin_fmaximum`.

Such a portable builtin would be quite useful:
- it implements `fmaximum` / `std::fmaximum` directly
- it already has a portable `llvm.maximum` intrinsic backing it
- on WASM, it lowers to a single `f32.max` or `f64.max` instruction
- on ARMv8, I think it lowers directly to `fmax`, though I'd need to double-check that
- it implements the ISO/IEC 60559 "maximum" operation

Contributor guide

Open the contributing guide

Research direction

Start by tracing the existing __builtin_fmax and __builtin_fmaximum_num implementations and their lowering to llvm.maximum. Add the missing __builtin_fmaximum behavior and verify that it lowers to the llvm.maximum intrinsic, including the f32 and f64 WebAssembly cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.