Skip to content

Uses of min, max, and others may not be optimal #1249

Description

@tgross35

It appears that rust-lang/rust#153343 introduced some mild regressions in hypot, which uses min and max. aarch64:

icount::icount_bench_math_group::icount_bench_hypot logspace:(setup_hypot())
  Baselines:                   arch_enabled|arch_enabled (old)
  Instructions:                       19914|18946                (+5.10926%) [+1.05109x]
  L1 Hits:                            21329|20360                (+4.75933%) [+1.04759x]
  LL Hits:                                0|1                    (-100.000%) [---inf---]
  RAM Hits:                              15|15                   (No change)
  Total read+write:                   21344|20376                (+4.75069%) [+1.04751x]
  Estimated Cycles:                   21854|20890                (+4.61465%) [+1.04615x]

x86-64:

icount::icount_bench_math_group::icount_bench_hypot logspace:(setup_hypot())
  Baselines:                   arch_enabled|arch_enabled (old)
  Instructions:                       40337|38446                (+4.91859%) [+1.04919x]
  L1 Hits:                            53116|51224                (+3.69358%) [+1.03694x]
  LL Hits:                                2|3                    (-33.3333%) [-1.50000x]
  RAM Hits:                              35|35                   (No change)
  Total read+write:                   53153|51262                (+3.68889%) [+1.03689x]
  Estimated Cycles:                   54351|52464                (+3.59675%) [+1.03597x]

From the CI runs at https://github.com/rust-lang/compiler-builtins/actions/runs/31156146463?pr=1248. I didn't bisect down to the specific commit but 2026-03-15 is fine and 2026-03-16 shows the regression. The lowering changed https://rust.godbolt.org/z/bbvY9jEPT

min:
        fminnm  d0, d0, d1
        ret
min:
        fminnm  d1, d1, d1
        fminnm  d0, d0, d0
        fminnm  d0, d0, d1
        ret

That change makes sense for rustc but we already know we're not dealing with NaN so we could use something better.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions