[llvm-branch-commits] [llvm] AMDGPU: Introduce f64 rsq pattern in AMDGPUCodeGenPrepare (PR #172053)
@@ -605,15 +608,117 @@ static Value *emitRsqIEEE1ULP(IRBuilder<> &Builder,
Value *Src,
return Builder.CreateFMul(Rsq, OutputScaleFactor);
}
+/// Emit inverse sqrt expansion for f64 with a correction sequence on top of
+/// v_rsq_f64. This should give a 1ulp result.
+Value *AMDGPUCodeGenPrepareImpl::emitRsqF64(IRBuilder<> &Builder, Value *X,
+FastMathFlags SqrtFMF,
+FastMathFlags DivFMF,
+const Instruction *CtxI,
+bool IsNegative) const {
+ // rsq(x):
+ // double y0 = BUILTIN_AMDGPU_RSQRT_F64(x);
+ // double e = MATH_MAD(-y0 * (x == PINF_F64 || x == 0.0 ? y0 : x), y0,
1.0);
+ // return MATH_MAD(y0*e, MATH_MAD(e, 0.375, 0.5), y0);
+ //
+ // The rsq instruction handles the special cases correctly. We need to check
+ // for the edge case conditions to ensure the special case propagates through
+ // the later instructions.
+
+ Value *Y0 = Builder.CreateUnaryIntrinsic(Intrinsic::amdgcn_rsq, X);
+
+ // Try to elide the edge case check.
+ //
+ // Fast math flags imply:
+ // sqrt ninf => !isinf(x)
+ // sqrt nnan => not helpful
+ // fdiv ninf => x != 0, !isinf(x)
+ // fdiv nnan => x != 0
+ bool MaybePosInf = !SqrtFMF.noInfs() && !DivFMF.noInfs();
+ bool MaybeZero = !DivFMF.noInfs() && !DivFMF.noNaNs();
+
+ DenormalMode DenormMode;
+ FPClassTest Interested = fcNone;
+ if (MaybeZero)
+Interested = fcZero;
+ if (MaybePosInf)
+Interested = fcPosInf;
+
+ if (Interested != fcNone) {
+KnownFPClass KnownSrc = computeKnownFPClass(X, Interested, CtxI);
+if (KnownSrc.isKnownNeverPosInfinity())
+ MaybePosInf = false;
+
+DenormMode = F.getDenormalMode(X->getType()->getFltSemantics());
+if (KnownSrc.isKnownNeverLogicalZero(DenormMode))
+ MaybeZero = false;
+ }
+
+ Value *SpecialOrRsq = Y0;
arsenm wrote:
Yes. The special case handling is to just avoid the FMA inf * 0 = nan case.
https://github.com/llvm/llvm-project/pull/172053
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/21.x: [llvm-offload-wrapper] Fix Triple and OpenMP handling (#167580) (PR #172151)
ZuseZ4 wrote: > This, I believe, comes from the Rust team wanting to more easily use this > utility. Yes indeed, I had asked for it for our rustc GPU efforts in https://github.com/rust-lang/rust-project-goals/issues/109 This PR had helped me with replacing the `clang-linker-wrapper` invocation, since in Cargo we don't generally want to call (additional) LLVM binaries. However, Joseph mentioned how I can work around it on the rust side. I didn't get to test it yet, but (worst case) we can vendor the fix for a few months on the Rust side till we get to update to LLVM-22, which will simplify our compilation pipeline anyway by quite a bit. Since you seem a bit concerned about the timeline, I guess either fix on the Rust side is preferred, so we can go with that. https://github.com/llvm/llvm-project/pull/172151 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] 274a44c - Revert "[clang-format] Continue aligned lines without parentheses (#167979)"
Author: owenca
Date: 2025-12-14T18:48:00-08:00
New Revision: 274a44cde05b71958ef67172730f0613e5a1addc
URL:
https://github.com/llvm/llvm-project/commit/274a44cde05b71958ef67172730f0613e5a1addc
DIFF:
https://github.com/llvm/llvm-project/commit/274a44cde05b71958ef67172730f0613e5a1addc.diff
LOG: Revert "[clang-format] Continue aligned lines without parentheses
(#167979)"
This reverts commit 75c85bafb830e5a7bd7fda13d2648180538ff513.
Added:
Modified:
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/ContinuationIndenter.h
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/lib/Format/WhitespaceManager.cpp
clang/lib/Format/WhitespaceManager.h
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/FormatTestObjC.cpp
Removed:
diff --git a/clang/lib/Format/ContinuationIndenter.cpp
b/clang/lib/Format/ContinuationIndenter.cpp
index 1272bb72d423f..9ab024a03fbd7 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -240,45 +240,6 @@ RawStringFormatStyleManager::getEnclosingFunctionStyle(
return It->second;
}
-IndentationAndAlignment
-IndentationAndAlignment::addPadding(unsigned Spaces) const {
- return IndentationAndAlignment(Total + Spaces, IndentedFrom);
-}
-
-IndentationAndAlignment
-IndentationAndAlignment::operator+(unsigned Spaces) const {
- return IndentationAndAlignment(Total + Spaces, Total);
-}
-
-IndentationAndAlignment
-IndentationAndAlignment::operator-(unsigned Spaces) const {
- return IndentationAndAlignment(Total - Spaces, Total);
-}
-
-IndentationAndAlignment &IndentationAndAlignment::operator+=(unsigned Spaces) {
- *this = *this + Spaces;
- return *this;
-}
-
-IndentationAndAlignment::IndentationAndAlignment(unsigned Total,
- unsigned IndentedFrom)
-: Total(Total), IndentedFrom(IndentedFrom) {}
-
-IndentationAndAlignment::IndentationAndAlignment(unsigned Spaces)
-: Total(Spaces), IndentedFrom(Spaces) {}
-
-bool IndentationAndAlignment::operator<(
-const IndentationAndAlignment &Other) const {
- if (Total != Other.Total)
-return Total < Other.Total;
- // The sign to use here was decided arbitrarily. This operator is mostly used
- // when a line's indentation should be the max of 2 things. Using this sign
- // here makes the program prefer alignment over continuation indentation.
That
- // is, it makes the alignment step that follows prefer to move the line when
- // aligning the previous line.
- return IndentedFrom > Other.IndentedFrom;
-}
-
ContinuationIndenter::ContinuationIndenter(const FormatStyle &Style,
const AdditionalKeywords &Keywords,
const SourceManager &SourceMgr,
@@ -530,7 +491,7 @@ bool ContinuationIndenter::mustBreak(const LineState
&State) {
return true;
}
- unsigned NewLineColumn = getNewLineColumn(State).Total;
+ unsigned NewLineColumn = getNewLineColumn(State);
if (Current.isMemberAccess() && Style.ColumnLimit != 0 &&
State.Column + getLengthToNextOperator(Current) > Style.ColumnLimit &&
(State.Column > NewLineColumn ||
@@ -858,9 +819,8 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState
&State, bool DryRun,
}
if (Current.is(TT_SelectorName) && !CurrentState.ObjCSelectorNameFound) {
-unsigned MinIndent =
-std::max(State.FirstIndent + Style.ContinuationIndentWidth,
- CurrentState.Indent.Total);
+unsigned MinIndent = std::max(
+State.FirstIndent + Style.ContinuationIndentWidth,
CurrentState.Indent);
unsigned FirstColonPos = State.Column + Spaces + Current.ColumnWidth;
if (Current.LongestObjCSelectorName == 0)
CurrentState.AlignColons = false;
@@ -950,8 +910,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState
&State, bool DryRun,
return !Next || Next->isMemberAccess() ||
Next->is(TT_FunctionDeclarationLParen) ||
IsFunctionCallParen(*Next);
};
- if (IsOpeningBracket(Previous) &&
- State.Column > getNewLineColumn(State).Total &&
+ if (IsOpeningBracket(Previous) && State.Column > getNewLineColumn(State) &&
// Don't do this for simple (no expressions) one-argument function calls
// as that feels like needlessly wasting whitespace, e.g.:
//
@@ -996,7 +955,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState
&State, bool DryRun,
CurrentState.NoLineBreak = true;
if (startsSegmentOfBuilderTypeCall(Current) &&
- State.Column > getNewLineColumn(State).Total) {
+ State.Column > getNewLineColumn(State)) {
CurrentState.ContainsUnwrappedBuilder = true;
}
@@ -1127,8 +1086,7 @@ unsigned
ContinuationIndenter::addTokenOnNewLine(LineState &State,
Penalty += Style.PenaltyBreakFirstLessLess;
}
- const auto [TotalColumn, Ind
[llvm-branch-commits] [mlir] db308ed - Revert "[MLIR][Transform][Python] transform.foreach wrapper and .owner OpView…"
Author: Mehdi Amini
Date: 2025-12-14T22:11:13+01:00
New Revision: db308edbab49611d3f1f15d3d77d43a4457007f3
URL:
https://github.com/llvm/llvm-project/commit/db308edbab49611d3f1f15d3d77d43a4457007f3
DIFF:
https://github.com/llvm/llvm-project/commit/db308edbab49611d3f1f15d3d77d43a4457007f3.diff
LOG: Revert "[MLIR][Transform][Python] transform.foreach wrapper and .owner
OpView…"
This reverts commit 4cdec92827e6901e077e7f50a382d6acabe7aaf0.
Added:
Modified:
mlir/lib/Bindings/Python/IRCore.cpp
mlir/python/mlir/dialects/memref.py
mlir/python/mlir/dialects/transform/__init__.py
mlir/test/python/dialects/transform.py
Removed:
diff --git a/mlir/lib/Bindings/Python/IRCore.cpp
b/mlir/lib/Bindings/Python/IRCore.cpp
index 168c57955af07..b0de14719ab61 100644
--- a/mlir/lib/Bindings/Python/IRCore.cpp
+++ b/mlir/lib/Bindings/Python/IRCore.cpp
@@ -1519,12 +1519,12 @@ class PyOpResult : public PyConcreteValue {
static void bindDerived(ClassTy &c) {
c.def_prop_ro(
"owner",
-[](PyOpResult &self) -> nb::typed {
+[](PyOpResult &self) -> nb::typed {
assert(mlirOperationEqual(self.getParentOperation()->get(),
mlirOpResultGetOwner(self.get())) &&
"expected the owner of the value in Python to match that in "
"the IR");
- return self.getParentOperation()->createOpView();
+ return self.getParentOperation().getObject();
},
"Returns the operation that produces this result.");
c.def_prop_ro(
@@ -4646,7 +4646,7 @@ void mlir::python::populateIRCore(nb::module_ &m) {
kDumpDocstring)
.def_prop_ro(
"owner",
- [](PyValue &self) -> nb::typed {
+ [](PyValue &self) -> nb::object {
MlirValue v = self.get();
if (mlirValueIsAOpResult(v)) {
assert(mlirOperationEqual(self.getParentOperation()->get(),
@@ -4654,7 +4654,7 @@ void mlir::python::populateIRCore(nb::module_ &m) {
"expected the owner of the value in Python to match "
"that in "
"the IR");
- return self.getParentOperation()->createOpView();
+ return self.getParentOperation().getObject();
}
if (mlirValueIsABlockArgument(v)) {
diff --git a/mlir/python/mlir/dialects/memref.py
b/mlir/python/mlir/dialects/memref.py
index c80a1b1a89358..bc9a3a52728ad 100644
--- a/mlir/python/mlir/dialects/memref.py
+++ b/mlir/python/mlir/dialects/memref.py
@@ -14,7 +14,8 @@
def _is_constant_int_like(i):
return (
isinstance(i, Value)
-and isinstance(i.owner, ConstantOp)
+and isinstance(i.owner, Operation)
+and isinstance(i.owner.opview, ConstantOp)
and _is_integer_like_type(i.type)
)
diff --git a/mlir/python/mlir/dialects/transform/__init__.py
b/mlir/python/mlir/dialects/transform/__init__.py
index fbe4078782997..b3dd79c7dbd79 100644
--- a/mlir/python/mlir/dialects/transform/__init__.py
+++ b/mlir/python/mlir/dialects/transform/__init__.py
@@ -310,8 +310,6 @@ def __init__(
sym_visibility=sym_visibility,
arg_attrs=arg_attrs,
res_attrs=res_attrs,
-loc=loc,
-ip=ip,
)
self.regions[0].blocks.append(*input_types)
@@ -470,54 +468,6 @@ def apply_registered_pass(
).result
-@_ods_cext.register_operation(_Dialect, replace=True)
-class ForeachOp(ForeachOp):
-def __init__(
-self,
-results: Sequence[Type],
-targets: Sequence[Union[Operation, Value, OpView]],
-*,
-with_zip_shortest: Optional[bool] = False,
-loc=None,
-ip=None,
-):
-targets = [_get_op_result_or_value(target) for target in targets]
-super().__init__(
-results_=results,
-targets=targets,
-with_zip_shortest=with_zip_shortest,
-loc=loc,
-ip=ip,
-)
-self.regions[0].blocks.append(*[target.type for target in targets])
-
-@property
-def body(self) -> Block:
-return self.regions[0].blocks[0]
-
-@property
-def bodyTargets(self) -> BlockArgumentList:
-return self.regions[0].blocks[0].arguments
-
-
-def foreach(
-results: Sequence[Type],
-targets: Sequence[Union[Operation, Value, OpView]],
-*,
-with_zip_shortest: Optional[bool] = False,
-loc=None,
-ip=None,
-) -> Union[OpResult, OpResultList, ForeachOp]:
-results = ForeachOp(
-results=results,
-targets=targets,
-with_zip_shortest=with_zip_shortest,
-loc=loc,
-ip=ip,
-).results
-return results if len(results) > 1 else (results[0] if len(results) == 1
else op)
-
-
AnyOpTypeT = NewType("AnyOpType", AnyOpType)
diff --git a/mlir/test/p
[llvm-branch-commits] [llvm] AMDGPU: Introduce f64 rsq pattern in AMDGPUCodeGenPrepare (PR #172053)
@@ -605,15 +608,117 @@ static Value *emitRsqIEEE1ULP(IRBuilder<> &Builder,
Value *Src,
return Builder.CreateFMul(Rsq, OutputScaleFactor);
}
+/// Emit inverse sqrt expansion for f64 with a correction sequence on top of
+/// v_rsq_f64. This should give a 1ulp result.
+Value *AMDGPUCodeGenPrepareImpl::emitRsqF64(IRBuilder<> &Builder, Value *X,
+FastMathFlags SqrtFMF,
+FastMathFlags DivFMF,
+const Instruction *CtxI,
+bool IsNegative) const {
+ // rsq(x):
+ // double y0 = BUILTIN_AMDGPU_RSQRT_F64(x);
+ // double e = MATH_MAD(-y0 * (x == PINF_F64 || x == 0.0 ? y0 : x), y0,
1.0);
+ // return MATH_MAD(y0*e, MATH_MAD(e, 0.375, 0.5), y0);
+ //
+ // The rsq instruction handles the special cases correctly. We need to check
+ // for the edge case conditions to ensure the special case propagates through
+ // the later instructions.
+
+ Value *Y0 = Builder.CreateUnaryIntrinsic(Intrinsic::amdgcn_rsq, X);
+
+ // Try to elide the edge case check.
+ //
+ // Fast math flags imply:
+ // sqrt ninf => !isinf(x)
+ // sqrt nnan => not helpful
+ // fdiv ninf => x != 0, !isinf(x)
+ // fdiv nnan => x != 0
+ bool MaybePosInf = !SqrtFMF.noInfs() && !DivFMF.noInfs();
+ bool MaybeZero = !DivFMF.noInfs() && !DivFMF.noNaNs();
+
+ DenormalMode DenormMode;
+ FPClassTest Interested = fcNone;
+ if (MaybeZero)
+Interested = fcZero;
+ if (MaybePosInf)
+Interested = fcPosInf;
+
+ if (Interested != fcNone) {
+KnownFPClass KnownSrc = computeKnownFPClass(X, Interested, CtxI);
+if (KnownSrc.isKnownNeverPosInfinity())
+ MaybePosInf = false;
+
+DenormMode = F.getDenormalMode(X->getType()->getFltSemantics());
+if (KnownSrc.isKnownNeverLogicalZero(DenormMode))
+ MaybeZero = false;
+ }
+
+ Value *SpecialOrRsq = Y0;
dtcxzyw wrote:
For normal cases, we should use `y0`, right?
https://github.com/llvm/llvm-project/pull/172053
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libunwind] release/21.x: [libunwind] fix building on Haiku i386 (#171586) (PR #171754)
https://github.com/brad0 updated
https://github.com/llvm/llvm-project/pull/171754
>From 01085318abfec9d8d1828877b4ec1f9b14efb68b Mon Sep 17 00:00:00 2001
From: Brad Smith
Date: Wed, 10 Dec 2025 21:27:21 -0500
Subject: [PATCH] [libunwind] fix building on Haiku i386 (#171586)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: Jérôme Duval
(cherry picked from commit 3fdce799cc184bf1b7c60a6845026df6c6e7630b)
---
libunwind/src/UnwindCursor.hpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 9a1afd3721f5a..1dcf2e14da851 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -41,7 +41,8 @@
#define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1
#endif
-#if defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64)
+#if defined(_LIBUNWIND_TARGET_HAIKU) &&
\
+(defined(_LIBUNWIND_TARGET_I386) || defined(_LIBUNWIND_TARGET_X86_64))
#include
#include
#define _LIBUNWIND_CHECK_HAIKU_SIGRETURN 1
@@ -1345,7 +1346,7 @@ class UnwindCursor : public AbstractUnwindCursor{
bool _unwindInfoMissing;
bool _isSignalFrame;
#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) ||
\
-defined(_LIBUNWIND_TARGET_HAIKU)
+defined(_LIBUNWIND_CHECK_HAIKU_SIGRETURN)
bool _isSigReturn = false;
#endif
};
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] AMDGPU: Introduce f64 rsq pattern in AMDGPUCodeGenPrepare (PR #172053)
@@ -605,15 +608,117 @@ static Value *emitRsqIEEE1ULP(IRBuilder<> &Builder,
Value *Src,
return Builder.CreateFMul(Rsq, OutputScaleFactor);
}
+/// Emit inverse sqrt expansion for f64 with a correction sequence on top of
+/// v_rsq_f64. This should give a 1ulp result.
+Value *AMDGPUCodeGenPrepareImpl::emitRsqF64(IRBuilder<> &Builder, Value *X,
+FastMathFlags SqrtFMF,
+FastMathFlags DivFMF,
+const Instruction *CtxI,
+bool IsNegative) const {
+ // rsq(x):
+ // double y0 = BUILTIN_AMDGPU_RSQRT_F64(x);
+ // double e = MATH_MAD(-y0 * (x == PINF_F64 || x == 0.0 ? y0 : x), y0,
1.0);
+ // return MATH_MAD(y0*e, MATH_MAD(e, 0.375, 0.5), y0);
+ //
+ // The rsq instruction handles the special cases correctly. We need to check
+ // for the edge case conditions to ensure the special case propagates through
+ // the later instructions.
+
+ Value *Y0 = Builder.CreateUnaryIntrinsic(Intrinsic::amdgcn_rsq, X);
+
+ // Try to elide the edge case check.
+ //
+ // Fast math flags imply:
+ // sqrt ninf => !isinf(x)
+ // sqrt nnan => not helpful
+ // fdiv ninf => x != 0, !isinf(x)
+ // fdiv nnan => x != 0
+ bool MaybePosInf = !SqrtFMF.noInfs() && !DivFMF.noInfs();
+ bool MaybeZero = !DivFMF.noInfs() && !DivFMF.noNaNs();
+
+ DenormalMode DenormMode;
+ FPClassTest Interested = fcNone;
+ if (MaybeZero)
+Interested = fcZero;
+ if (MaybePosInf)
+Interested = fcPosInf;
+
+ if (Interested != fcNone) {
+KnownFPClass KnownSrc = computeKnownFPClass(X, Interested, CtxI);
+if (KnownSrc.isKnownNeverPosInfinity())
+ MaybePosInf = false;
+
+DenormMode = F.getDenormalMode(X->getType()->getFltSemantics());
+if (KnownSrc.isKnownNeverLogicalZero(DenormMode))
+ MaybeZero = false;
+ }
+
+ Value *SpecialOrRsq = Y0;
arsenm wrote:
This __internal_fast_rsqrt seems to not handle the nonfinite edge cases?
My reference is
https://github.com/ROCm/llvm-project/blob/2a85673b4a25ae7ac13177ec62d7daa226a79126/amd/device-libs/ocml/src/rsqrtD.cl
(which I just shuffled around to make the edge case pruning easier)
https://github.com/llvm/llvm-project/pull/172053
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/21.x: [llvm-offload-wrapper] Fix Triple and OpenMP handling (#167580) (PR #172151)
dyung wrote: Hi, thanks for the explanation, but I think I am going to pass on integrating this change for the 21.x release, but 22.x is just a little over a month away so hopefully your issue gets better soon with that! https://github.com/llvm/llvm-project/pull/172151 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [Backport][MLIR] Properties.td fix from main commit 77f2560 (PR #165768)
dyung wrote: ping @fabianmcg https://github.com/llvm/llvm-project/pull/165768 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
