Manual-sync mirror of chromium.googlesource.com/external/github.com/llvm/llvm-project (bare monorepo, no subtree suffix)
Find a file
wanglei b8918e6248 [LoongArch] Fix incorrect reciprocal sqrt estimate semantics (#187621)
The current implementation of getSqrtEstimate() has incorrect semantics
when using `FRSQRTE`.

`FRSQRTE` computes an approximation to 1/sqrt(x), but the existing code
multiplies the estimate by the operand when Reciprocal is true. This
results in returning sqrt(x) instead of 1/sqrt(x), effectively reversing
the intended semantics of the 'Reciprocal' flag.

Additionally, the implementation does not properly account for LLVM's
Newton-Raphson refinement pipeline. When refinement steps are requested,
the initial estimate must be in reciprocal form so that the generic
DAGCombiner can apply NR iterations correctly.

This patch fixes the behavior by:

- Returning the raw FRSQRTE result when Reciprocal is true, or when
  refinement steps are required.
- Only reconstructing sqrt(x) via x * rsqrt(x) when no refinement is
  requested.
- Refactoring type checks into a helper function
(isSupportedReciprocalEstimateType)
  for improved readability and maintainability.

The updated implementation aligns with the expectations of LLVM's
reciprocal estimate framework and matches the behavior of other targets
such as X86 and AArch64.

No functional change when reciprocal estimates are disabled, but fixes
incorrect results when fast-math enables reciprocal sqrt estimates.

Fixes #186328

(cherry picked from commit 6ae5803ffd)
2026-03-30 15:04:50 +00:00
.ci [green dragon] add stage1-RA job to release/22.x 2026-03-06 18:42:38 +00:00
.github workflows/release-binaries: Pass missing release-version input to upload-release-artifact (#180879) 2026-02-16 09:01:46 +00:00
bolt [BOLT] Avoid UB due to misaligned access. (#174990) 2026-01-10 03:45:13 +00:00
clang [MC,clang] Fix -Wa,--noexecstack not emitting .note.GNU-stack (#187880) 2026-03-30 15:00:51 +00:00
clang-tools-extra release/22.x: Backport workarounds for certain addMatcher overloads ignoring traversal kind 2026-03-18 21:20:48 +00:00
cmake Bump version to 22.1.3 2026-03-24 20:03:33 +00:00
compiler-rt [ubsan][test] Skip Misc/Posix/static-link.cpp on Solaris (#175464) 2026-02-09 09:55:00 +00:00
cross-project-tests [TEST][FIX] Fix typo in tool name: 'llvm-ar' 2026-02-18 08:19:19 +00:00
flang [flang][ReleaseNotes] Add do concurrent parallelization note 2026-02-23 15:31:19 +00:00
flang-rt [flang-rt] Fix system_clock scaling on MacOS (#176753) 2026-01-23 07:36:09 +00:00
libc [libc] Fix unit test dependency and respect LIBC_INCLUDE_BENCHMARKS (#180812) 2026-02-12 07:59:24 +00:00
libclc [Backport][Clang] Rename uinc_wrap and add normal atomic builtin 2026-02-05 08:04:18 +00:00
libcxx Bump version to 22.1.3 2026-03-24 20:03:33 +00:00
libcxxabi [libc++][NFC] Refactor _LIBCPP_OVERRIDABLE_FUNCTION to be a normal attribute macro (#174964) 2026-01-09 12:07:42 +01:00
libsycl [libsycl] fix license link in README.md. 2025-12-01 16:34:37 -05:00
libunwind [libunwind] Fix building on OpenBSD / FreeBSD aarch64 (#188397) 2026-03-27 08:46:19 +00:00
lld [LLD] [ELF] Make -z gcs=always implicitly warn on missing GCS, like force-bti (#186203) 2026-03-23 03:20:01 +00:00
lldb [lldb] use the Py_REFCNT() macro instead of directly accessing member (#188161) 2026-03-27 08:45:31 +00:00
llvm [LoongArch] Fix incorrect reciprocal sqrt estimate semantics (#187621) 2026-03-30 15:04:50 +00:00
llvm-libgcc
mlir [MLIR][SCFToOpenMP] Fix crash when lowering vector reductions (#173978) 2026-01-15 09:49:53 +00:00
offload [NFC][Offload] Rename a function (#175673) 2026-01-12 19:40:17 -06:00
openmp [openmp][tests] Fix bug63197.c (#183508) 2026-03-05 17:41:50 +00:00
orc-rt [orc-rt] Add Maintainers.md. (#175691) 2026-01-13 12:08:27 +11:00
polly [Polly][ScopInfo] Lazy Scop instantiation (#179535) 2026-02-23 08:31:55 +00:00
runtimes [libc++] Enable -Wmissing-prototypes (#116261) 2025-12-16 11:25:07 +01:00
third-party [Benchmark] Fix warnings around usage of __COUNTER__ (#184524) 2026-03-05 14:33:27 +00:00
utils/bazel Fix Bazel build for e289b2e (#175642) 2026-01-12 15:52:31 -05:00
.clang-format Enforce Unix line endings for Clang/LLVM/MLIR projects (#161460) 2025-10-02 06:09:12 -07:00
.clang-format-ignore Add empty top level .clang-format-ignore (#136022) 2025-04-16 15:48:30 -07:00
.clang-tidy Add default empty header filter regex to root .clang-tidy (#167386) 2025-11-11 01:36:25 +03:00
.git-blame-ignore-revs [clang-tidy][NFC] Add clang-tidy formatting commit to .git-blame-ignore-revs (#167126) 2025-11-20 21:42:10 +08:00
.gitattributes [libclang/python] Enable packaging clang python bindings (#125806) 2025-11-24 17:21:24 -08:00
.gitignore [LLVM] Ignore two Cursor specific files. (#175683) 2026-01-13 02:27:05 +01:00
.mailmap
CODE_OF_CONDUCT.md
CONTRIBUTING.md [www][docs] Remove last mentions of IRC (#139076) 2025-05-08 09:40:33 -04:00
LICENSE.TXT
pyproject.toml [lldb] Configure pyright to the documented minimum python version (#162952) 2025-11-20 10:30:22 -08:00
README.md
SECURITY.md

The LLVM Compiler Infrastructure

OpenSSF Scorecard OpenSSF Best Practices libc++

Welcome to the LLVM project!

This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.

The LLVM project has multiple components. The core of the project is itself called "LLVM". This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.

C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.

Other components include: the libc++ C++ standard library, the LLD linker, and more.

Getting the Source Code and Building LLVM

Consult the Getting Started with LLVM page for information on building and running LLVM.

For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.

Getting in touch

Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.

The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.