[clang] [llvm] Implement operand bundles for floating-point operations (PR #109798)

2024-09-27 Thread Serge Pavlov via cfe-commits
@@ -47,6 +47,15 @@ enum class RoundingMode : int8_t { Invalid = -1///< Denotes invalid value. }; +inline bool isValidRoundingMode(int X) { + return X >= 0 && X <= static_cast(RoundingMode::Dynamic); spavloff wrote: This is bad function name. Actually s

[clang] [llvm] Implement operand bundles for floating-point operations (PR #109798)

2024-09-27 Thread Serge Pavlov via cfe-commits
@@ -4282,6 +4282,64 @@ static void upgradeDbgIntrinsicToDbgRecord(StringRef Name, CallBase *CI) { CI->getParent()->insertDbgRecordBefore(DR, CI->getIterator()); } +static CallBase *upgradeConstrainedIntrinsicCall(CallBase *CB, Function *F, +

[clang] [clang] Set FPOptions at the beginning of CompoundStmt (PR #111654)

2024-11-18 Thread Serge Pavlov via cfe-commits
spavloff wrote: `FPOptions` were added to `CompoundStmt` to help code generation for `#pragma STDC FENV_ROUND`. If dynamic rounding is used, compiler should emit a code that switch it. There is no AST nodes for pragmas, so there is no a good place to emit such code. To solve this problem Compo

[clang] [llvm] Implement operand bundles for floating-point operations (PR #109798)

2024-12-01 Thread Serge Pavlov via cfe-commits
spavloff wrote: ### Merge activity * **Dec 2, 1:35 AM EST**: The merge label 'FP Bundles' was detected. This PR will be added to the [Graphite merge queue](https://app.graphite.dev/merges?org=llvm&repo=llvm-project) once it meets the requirements. https://github.com/llvm/llvm-project/pull/1

[clang] [llvm] Reimplement constrained 'trunc' using operand bundles (PR #118253)

2024-12-01 Thread Serge Pavlov via cfe-commits
spavloff wrote: ### Merge activity * **Dec 2, 12:55 AM EST**: The merge label 'FP Bundles' was detected. This PR will be added to the [Graphite merge queue](https://app.graphite.dev/merges?org=llvm&repo=llvm-project) once it meets the requirements. https://github.com/llvm/llvm-project/pull/

[clang] [llvm] Implement operand bundles for floating-point operations (PR #109798)

2024-12-01 Thread Serge Pavlov via cfe-commits
spavloff wrote: PR https://github.com/llvm/llvm-project/pull/118253 demonstrates changes required to upgrade an intrinsic (`trunc` in this case) to using FP operand bundles. https://github.com/llvm/llvm-project/pull/109798 ___ cfe-commits mailing li

[clang] [llvm] Implement operand bundles for floating-point operations (PR #109798)

2024-12-05 Thread Serge Pavlov via cfe-commits
@@ -273,29 +306,6 @@ void InstrProfCallsite::setCallee(Value *Callee) { setArgOperand(4, Callee); } -std::optional ConstrainedFPIntrinsic::getRoundingMode() const { - unsigned NumOperands = arg_size(); - Metadata *MD = nullptr; - auto *MAV = dyn_cast(getArgOperand(NumOper

[clang] [llvm] [IR] Don't set strictfp on irrelevant calls (PR #122735)

2025-02-04 Thread Serge Pavlov via cfe-commits
spavloff wrote: Thank you for the clarification. Let's keep the meaning of this attribute as it currently stands. The explanations raises some concern, though. OK, strictfp at call sites keeps previous property of the call even if the basic block is detached. If a block is taken from a stric

[clang] [llvm] Reimplement constrained 'trunc' using operand bundles (PR #118253)

2024-12-16 Thread Serge Pavlov via cfe-commits
@@ -86,6 +86,43 @@ IRBuilderBase::createCallHelper(Function *Callee, ArrayRef Ops, return CI; } +CallInst *IRBuilderBase::CreateCall(FunctionType *FTy, Value *Callee, +ArrayRef Args, +ArrayRef OpBundles

[clang] [llvm] [IR] Don't set strictfp on irrelevant calls (PR #122735)

2025-01-22 Thread Serge Pavlov via cfe-commits
spavloff wrote: > > If strict floating-point semantics are required at this call site, they are > > are required on every relevant call in this function. It means strictfp is > > a function attribute. Does anything prevents us from removal strictfp from > > all call sites? > > I think that tak

[clang] [llvm] [IR] Don't set strictfp on irrelevant calls (PR #122735)

2025-01-20 Thread Serge Pavlov via cfe-commits
spavloff wrote: > My understanding of the attribute is that it only indicates that strict > floating-point semantics are (potentially?) required at the call site. If strict floating-point semantics are required at this call site, they are are required on every relevant call in this function.

[clang] [llvm] [IR] Don't set strictfp on irrelevant calls (PR #122735)

2025-01-13 Thread Serge Pavlov via cfe-commits
spavloff wrote: This patch was obtained from the commit "Don't set strictfp on irrelevant calls" from #109798. https://github.com/llvm/llvm-project/pull/122735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mail

[clang] [llvm] [IR] Don't set strictfp on irrelevant calls (PR #122735)

2025-01-14 Thread Serge Pavlov via cfe-commits
@@ -66,6 +66,17 @@ bool IntrinsicInst::mayLowerToFunctionCall(Intrinsic::ID IID) { } } +bool IntrinsicInst::canAccessFPEnvironment(Intrinsic::ID IID) { + switch (IID) { +#define DAG_INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN) \ +case Intrinsic::INTR

[clang] [llvm] [IR] Don't set strictfp on irrelevant calls (PR #122735)

2025-01-14 Thread Serge Pavlov via cfe-commits
@@ -66,6 +66,12 @@ bool IntrinsicInst::mayLowerToFunctionCall(Intrinsic::ID IID) { } } +bool IntrinsicInst::canAccessFPEnvironment(LLVMContext &C, Intrinsic::ID IID) { + AttributeList Attrs = Intrinsic::getAttributes(C, IID); + MemoryEffects ME = Attrs.getMemoryEffects();

[clang] [llvm] [IR] Don't set strictfp on irrelevant calls (PR #122735)

2025-01-17 Thread Serge Pavlov via cfe-commits
spavloff wrote: Thank you for your retrospective view on `strictfp`. I didn't realize how much it is related to inlining. This use case should be carefully analyzed to refine meaning of the attribute. > Clearly intrinisics don't get inlined by the Inliner. But what if an > intrinsic gets lowe

[clang] Move const qualification of array to its elements (PR #131366)

2025-03-17 Thread Serge Pavlov via cfe-commits
spavloff wrote: MR https://github.com/llvm/llvm-project/pull/131649 implements an alternative fix to the problem. https://github.com/llvm/llvm-project/pull/131366 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/m

[clang] [clang] Fix array types comparison in getCommonSugaredType (PR #131649)

2025-03-17 Thread Serge Pavlov via cfe-commits
https://github.com/spavloff created https://github.com/llvm/llvm-project/pull/131649 Const-qualification of an array caused by constexpr specifier can produce QualType, where the const qualifier is set both as fast qualifier and as a qualifier of the array element type. It can result in a comp

[clang] Move const qualification of array to its elements (PR #131366)

2025-03-17 Thread Serge Pavlov via cfe-commits
https://github.com/spavloff closed https://github.com/llvm/llvm-project/pull/131366 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Move const qualification of array to its elements (PR #131366)

2025-03-14 Thread Serge Pavlov via cfe-commits
https://github.com/spavloff created https://github.com/llvm/llvm-project/pull/131366 Const-qualification of an array caused by constexpr specifier can produce QualType, where the const qualifier is set both as fast qualifier and as a qualifier of the array element type. It can result in a comp

[clang] [clang] Fix array types comparison in getCommonSugaredType (PR #131649)

2025-03-19 Thread Serge Pavlov via cfe-commits
https://github.com/spavloff updated https://github.com/llvm/llvm-project/pull/131649 >From cdf9f1a5b960d2561a7c4415313b397578de0f8b Mon Sep 17 00:00:00 2001 From: Serge Pavlov Date: Mon, 17 Mar 2025 21:33:24 +0700 Subject: [PATCH 1/2] [clang] Fix array types comparison in getCommonSugaredType

[clang] [clang] Fix array types comparison in getCommonSugaredType (PR #131649)

2025-03-19 Thread Serge Pavlov via cfe-commits
@@ -14171,6 +14171,15 @@ static QualType getCommonSugarTypeNode(ASTContext &Ctx, const Type *X, static auto unwrapSugar(SplitQualType &T, Qualifiers &QTotal) { SmallVector R; while (true) { +if (const auto *ATy = dyn_cast(T.Ty)) { + // C++ 9.3.3.4p3: Any type of t

[clang] [clang] Fix array types comparison in getCommonSugaredType (PR #131649)

2025-03-19 Thread Serge Pavlov via cfe-commits
@@ -14171,6 +14171,15 @@ static QualType getCommonSugarTypeNode(ASTContext &Ctx, const Type *X, static auto unwrapSugar(SplitQualType &T, Qualifiers &QTotal) { SmallVector R; while (true) { +if (const auto *ATy = dyn_cast(T.Ty)) { + // C++ 9.3.3.4p3: Any type of t

[clang] [clang] ASTContex: fix getCommonSugaredType for array types (PR #132559)

2025-03-25 Thread Serge Pavlov via cfe-commits
https://github.com/spavloff approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/132559 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix array types comparison in getCommonSugaredType (PR #131649)

2025-03-26 Thread Serge Pavlov via cfe-commits
spavloff wrote: Fixed in https://github.com/llvm/llvm-project/pull/132559. https://github.com/llvm/llvm-project/pull/131649 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix array types comparison in getCommonSugaredType (PR #131649)

2025-04-04 Thread Serge Pavlov via cfe-commits
https://github.com/spavloff closed https://github.com/llvm/llvm-project/pull/131649 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix array types comparison in getCommonSugaredType (PR #131649)

2025-04-05 Thread Serge Pavlov via cfe-commits
@@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -triple x86_64-linux-gnu %s + +bool a; +constexpr const unsigned char c[] = { 5 }; +constexpr const unsigned char d[1] = { 0 }; +auto b = (a ? d : c); + +constexpr const unsigned char c1[][1] = {{ 5 }}; +constexpr const unsigned char d1[1][1] =

<    1   2   3   4   5