[llvm-branch-commits] [llvm] [x86][Windows] Fix chromium build break (PR #111218)
farzonl wrote: @efriedma-quic I don't have permissions to merge to the 19.x branch. If you think its ready please merge at your discression. https://github.com/llvm/llvm-project/pull/111218 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/19.x: [x86] combineMUL - when looking for a vector multiply by splat constant, ensure we're only accepting ConstantInt splat scalars. (PR #111246)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/111246 Backport 9459d729d22b7bfedad9d3a4237162077c6984a4 Requested by: @RKSimon >From d3a82b2fa5d60c3aad20767bb30a76fdbef4c3f7 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Fri, 4 Oct 2024 18:09:53 +0100 Subject: [PATCH] [x86] combineMUL - when looking for a vector multiply by splat constant, ensure we're only accepting ConstantInt splat scalars. Fixes #70 (cherry picked from commit 9459d729d22b7bfedad9d3a4237162077c6984a4) --- llvm/lib/Target/X86/X86ISelLowering.cpp | 3 ++- llvm/test/CodeGen/X86/pr70.ll | 33 + 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 llvm/test/CodeGen/X86/pr70.ll diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 45989bcd07d37e..71730070c2a5b5 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -47893,7 +47893,8 @@ static SDValue combineMul(SDNode *N, SelectionDAG &DAG, if (VT.isVector()) if (auto *RawC = getTargetConstantFromNode(N->getOperand(1))) if (auto *SplatC = RawC->getSplatValue()) - C = &(SplatC->getUniqueInteger()); + if (auto *SplatCI = dyn_cast(SplatC)) +C = &(SplatCI->getValue()); if (!C || C->getBitWidth() != VT.getScalarSizeInBits()) return SDValue(); diff --git a/llvm/test/CodeGen/X86/pr70.ll b/llvm/test/CodeGen/X86/pr70.ll new file mode 100644 index 00..145bf7119edcb9 --- /dev/null +++ b/llvm/test/CodeGen/X86/pr70.ll @@ -0,0 +1,33 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 +; RUN: llc < %s -mtriple=i686-pc-windows-msvc -mcpu=corei7-avx | FileCheck %s + +define void @PR70(<16 x i32> %x_load, ptr %offsetsPtr.i) { +; CHECK-LABEL: PR70: +; CHECK: # %bb.0: +; CHECK-NEXT:movl {{[0-9]+}}(%esp), %eax +; CHECK-NEXT:vbroadcastss {{.*#+}} xmm2 = [2.80259693E-44,2.80259693E-44,2.80259693E-44,2.80259693E-44] +; CHECK-NEXT:vpmulld %xmm2, %xmm1, %xmm3 +; CHECK-NEXT:vextractf128 $1, %ymm1, %xmm1 +; CHECK-NEXT:vpmulld %xmm2, %xmm1, %xmm1 +; CHECK-NEXT:vpmulld %xmm2, %xmm0, %xmm4 +; CHECK-NEXT:vextractf128 $1, %ymm0, %xmm0 +; CHECK-NEXT:vpmulld %xmm2, %xmm0, %xmm0 +; CHECK-NEXT:vmovdqu %xmm0, 16(%eax) +; CHECK-NEXT:vmovdqu %xmm4, (%eax) +; CHECK-NEXT:vmovdqu %xmm1, 48(%eax) +; CHECK-NEXT:vmovdqu %xmm3, 32(%eax) +; CHECK-NEXT:vpxor %xmm0, %xmm0, %xmm0 +; CHECK-NEXT:vmovdqu %xmm0, 16 +; CHECK-NEXT:vmovdqu %xmm0, 0 +; CHECK-NEXT:vmovdqu %xmm0, 48 +; CHECK-NEXT:vmovdqu %xmm0, 32 +; CHECK-NEXT:vzeroupper +; CHECK-NEXT:retl + %mul__x_load = mul <16 x i32> , %x_load + store <16 x i32> %mul__x_load, ptr %offsetsPtr.i, align 4 + %blend1.i12.i = call <8 x float> @llvm.x86.avx.blendv.ps.256(<8 x float> zeroinitializer, <8 x float> , <8 x float> zeroinitializer) + %blend.i13.i = shufflevector <8 x float> zeroinitializer, <8 x float> %blend1.i12.i, <16 x i32> + %blendAsInt.i14.i = bitcast <16 x float> %blend.i13.i to <16 x i32> + store <16 x i32> %blendAsInt.i14.i, ptr null, align 4 + ret void +} ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/19.x: [x86] combineMUL - when looking for a vector multiply by splat constant, ensure we're only accepting ConstantInt splat scalars. (PR #111246)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/111246 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/19.x: [x86] combineMUL - when looking for a vector multiply by splat constant, ensure we're only accepting ConstantInt splat scalars. (PR #111246)
llvmbot wrote: @llvm/pr-subscribers-backend-x86 Author: None (llvmbot) Changes Backport 9459d729d22b7bfedad9d3a4237162077c6984a4 Requested by: @RKSimon --- Full diff: https://github.com/llvm/llvm-project/pull/111246.diff 2 Files Affected: - (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+2-1) - (added) llvm/test/CodeGen/X86/pr70.ll (+33) ``diff diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 45989bcd07d37e..71730070c2a5b5 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -47893,7 +47893,8 @@ static SDValue combineMul(SDNode *N, SelectionDAG &DAG, if (VT.isVector()) if (auto *RawC = getTargetConstantFromNode(N->getOperand(1))) if (auto *SplatC = RawC->getSplatValue()) - C = &(SplatC->getUniqueInteger()); + if (auto *SplatCI = dyn_cast(SplatC)) +C = &(SplatCI->getValue()); if (!C || C->getBitWidth() != VT.getScalarSizeInBits()) return SDValue(); diff --git a/llvm/test/CodeGen/X86/pr70.ll b/llvm/test/CodeGen/X86/pr70.ll new file mode 100644 index 00..145bf7119edcb9 --- /dev/null +++ b/llvm/test/CodeGen/X86/pr70.ll @@ -0,0 +1,33 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 +; RUN: llc < %s -mtriple=i686-pc-windows-msvc -mcpu=corei7-avx | FileCheck %s + +define void @PR70(<16 x i32> %x_load, ptr %offsetsPtr.i) { +; CHECK-LABEL: PR70: +; CHECK: # %bb.0: +; CHECK-NEXT:movl {{[0-9]+}}(%esp), %eax +; CHECK-NEXT:vbroadcastss {{.*#+}} xmm2 = [2.80259693E-44,2.80259693E-44,2.80259693E-44,2.80259693E-44] +; CHECK-NEXT:vpmulld %xmm2, %xmm1, %xmm3 +; CHECK-NEXT:vextractf128 $1, %ymm1, %xmm1 +; CHECK-NEXT:vpmulld %xmm2, %xmm1, %xmm1 +; CHECK-NEXT:vpmulld %xmm2, %xmm0, %xmm4 +; CHECK-NEXT:vextractf128 $1, %ymm0, %xmm0 +; CHECK-NEXT:vpmulld %xmm2, %xmm0, %xmm0 +; CHECK-NEXT:vmovdqu %xmm0, 16(%eax) +; CHECK-NEXT:vmovdqu %xmm4, (%eax) +; CHECK-NEXT:vmovdqu %xmm1, 48(%eax) +; CHECK-NEXT:vmovdqu %xmm3, 32(%eax) +; CHECK-NEXT:vpxor %xmm0, %xmm0, %xmm0 +; CHECK-NEXT:vmovdqu %xmm0, 16 +; CHECK-NEXT:vmovdqu %xmm0, 0 +; CHECK-NEXT:vmovdqu %xmm0, 48 +; CHECK-NEXT:vmovdqu %xmm0, 32 +; CHECK-NEXT:vzeroupper +; CHECK-NEXT:retl + %mul__x_load = mul <16 x i32> , %x_load + store <16 x i32> %mul__x_load, ptr %offsetsPtr.i, align 4 + %blend1.i12.i = call <8 x float> @llvm.x86.avx.blendv.ps.256(<8 x float> zeroinitializer, <8 x float> , <8 x float> zeroinitializer) + %blend.i13.i = shufflevector <8 x float> zeroinitializer, <8 x float> %blend1.i12.i, <16 x i32> + %blendAsInt.i14.i = bitcast <16 x float> %blend.i13.i to <16 x i32> + store <16 x i32> %blendAsInt.i14.i, ptr null, align 4 + ret void +} `` https://github.com/llvm/llvm-project/pull/111246 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [clang-format] Handle template closer followed by empty paretheses (#… (PR #111245)
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/111245 …110408) Fixes #109925. >From 8f516b15b30f7d17f82f958e758e448929c6e9a1 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Wed, 2 Oct 2024 19:06:56 -0700 Subject: [PATCH] [clang-format] Handle template closer followed by empty paretheses (#110408) Fixes #109925. --- clang/lib/Format/TokenAnnotator.cpp | 42 ++- clang/lib/Format/UnwrappedLineParser.cpp | 12 -- clang/unittests/Format/TokenAnnotatorTest.cpp | 7 3 files changed, 38 insertions(+), 23 deletions(-) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 4512e539cc7947..ad9ed7b47d002c 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -189,25 +189,29 @@ class AnnotatingParser { next(); } -for (bool SeenTernaryOperator = false; CurrentToken;) { +for (bool SeenTernaryOperator = false, MaybeAngles = true; CurrentToken;) { const bool InExpr = Contexts[Contexts.size() - 2].IsExpression; if (CurrentToken->is(tok::greater)) { const auto *Next = CurrentToken->Next; -// Try to do a better job at looking for ">>" within the condition of -// a statement. Conservatively insert spaces between consecutive ">" -// tokens to prevent splitting right bitshift operators and potentially -// altering program semantics. This check is overly conservative and -// will prevent spaces from being inserted in select nested template -// parameter cases, but should not alter program semantics. -if (Next && Next->is(tok::greater) && -Left->ParentBracket != tok::less && -CurrentToken->getStartOfNonWhitespace() == -Next->getStartOfNonWhitespace().getLocWithOffset(-1)) { - return false; -} -if (InExpr && SeenTernaryOperator && -(!Next || !Next->isOneOf(tok::l_paren, tok::l_brace))) { - return false; +if (CurrentToken->isNot(TT_TemplateCloser)) { + // Try to do a better job at looking for ">>" within the condition of + // a statement. Conservatively insert spaces between consecutive ">" + // tokens to prevent splitting right shift operators and potentially + // altering program semantics. This check is overly conservative and + // will prevent spaces from being inserted in select nested template + // parameter cases, but should not alter program semantics. + if (Next && Next->is(tok::greater) && + Left->ParentBracket != tok::less && + CurrentToken->getStartOfNonWhitespace() == + Next->getStartOfNonWhitespace().getLocWithOffset(-1)) { +return false; + } + if (InExpr && SeenTernaryOperator && + (!Next || !Next->isOneOf(tok::l_paren, tok::l_brace))) { +return false; + } + if (!MaybeAngles) +return false; } Left->MatchingParen = CurrentToken; CurrentToken->MatchingParen = Left; @@ -243,11 +247,11 @@ class AnnotatingParser { // operator that was misinterpreted because we are parsing template // parameters. // FIXME: This is getting out of hand, write a decent parser. - if (InExpr && !Line.startsWith(tok::kw_template) && + if (MaybeAngles && InExpr && !Line.startsWith(tok::kw_template) && Prev.is(TT_BinaryOperator)) { const auto Precedence = Prev.getPrecedence(); if (Precedence > prec::Conditional && Precedence < prec::Relational) - return false; + MaybeAngles = false; } if (Prev.isOneOf(tok::question, tok::colon) && !Style.isProto()) SeenTernaryOperator = true; @@ -1615,7 +1619,7 @@ class AnnotatingParser { return false; break; case tok::greater: - if (Style.Language != FormatStyle::LK_TextProto) + if (Style.Language != FormatStyle::LK_TextProto && Tok->is(TT_Unknown)) Tok->setType(TT_BinaryOperator); if (Tok->Previous && Tok->Previous->is(TT_TemplateCloser)) Tok->SpacesRequiredBefore = 1; diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 7813d86ff0ea10..f7b3561f6e0335 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -2551,7 +2551,7 @@ bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) { parseChildBlock(); break; case tok::r_paren: { - const auto *Prev = LeftParen->Previous; + auto *Prev = LeftParen->Previous; if (!MightBeStmtExpr && !MightBeFoldExpr && !Line->InMacroBody && Style.RemoveParentheses > FormatStyle::RPS_Leave) { const auto *Next = Tokens->peekNextToken(); @@ -2575,9 +2575,13 @@ bool UnwrappedLineParser::parseParens(TokenType Am
[llvm-branch-commits] [clang] [clang-format] Handle template closer followed by empty paretheses (#… (PR #111245)
llvmbot wrote: @llvm/pr-subscribers-clang-format Author: Owen Pan (owenca) Changes …110408) Fixes #109925. --- Full diff: https://github.com/llvm/llvm-project/pull/111245.diff 3 Files Affected: - (modified) clang/lib/Format/TokenAnnotator.cpp (+23-19) - (modified) clang/lib/Format/UnwrappedLineParser.cpp (+8-4) - (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+7) ``diff diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 4512e539cc7947..ad9ed7b47d002c 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -189,25 +189,29 @@ class AnnotatingParser { next(); } -for (bool SeenTernaryOperator = false; CurrentToken;) { +for (bool SeenTernaryOperator = false, MaybeAngles = true; CurrentToken;) { const bool InExpr = Contexts[Contexts.size() - 2].IsExpression; if (CurrentToken->is(tok::greater)) { const auto *Next = CurrentToken->Next; -// Try to do a better job at looking for ">>" within the condition of -// a statement. Conservatively insert spaces between consecutive ">" -// tokens to prevent splitting right bitshift operators and potentially -// altering program semantics. This check is overly conservative and -// will prevent spaces from being inserted in select nested template -// parameter cases, but should not alter program semantics. -if (Next && Next->is(tok::greater) && -Left->ParentBracket != tok::less && -CurrentToken->getStartOfNonWhitespace() == -Next->getStartOfNonWhitespace().getLocWithOffset(-1)) { - return false; -} -if (InExpr && SeenTernaryOperator && -(!Next || !Next->isOneOf(tok::l_paren, tok::l_brace))) { - return false; +if (CurrentToken->isNot(TT_TemplateCloser)) { + // Try to do a better job at looking for ">>" within the condition of + // a statement. Conservatively insert spaces between consecutive ">" + // tokens to prevent splitting right shift operators and potentially + // altering program semantics. This check is overly conservative and + // will prevent spaces from being inserted in select nested template + // parameter cases, but should not alter program semantics. + if (Next && Next->is(tok::greater) && + Left->ParentBracket != tok::less && + CurrentToken->getStartOfNonWhitespace() == + Next->getStartOfNonWhitespace().getLocWithOffset(-1)) { +return false; + } + if (InExpr && SeenTernaryOperator && + (!Next || !Next->isOneOf(tok::l_paren, tok::l_brace))) { +return false; + } + if (!MaybeAngles) +return false; } Left->MatchingParen = CurrentToken; CurrentToken->MatchingParen = Left; @@ -243,11 +247,11 @@ class AnnotatingParser { // operator that was misinterpreted because we are parsing template // parameters. // FIXME: This is getting out of hand, write a decent parser. - if (InExpr && !Line.startsWith(tok::kw_template) && + if (MaybeAngles && InExpr && !Line.startsWith(tok::kw_template) && Prev.is(TT_BinaryOperator)) { const auto Precedence = Prev.getPrecedence(); if (Precedence > prec::Conditional && Precedence < prec::Relational) - return false; + MaybeAngles = false; } if (Prev.isOneOf(tok::question, tok::colon) && !Style.isProto()) SeenTernaryOperator = true; @@ -1615,7 +1619,7 @@ class AnnotatingParser { return false; break; case tok::greater: - if (Style.Language != FormatStyle::LK_TextProto) + if (Style.Language != FormatStyle::LK_TextProto && Tok->is(TT_Unknown)) Tok->setType(TT_BinaryOperator); if (Tok->Previous && Tok->Previous->is(TT_TemplateCloser)) Tok->SpacesRequiredBefore = 1; diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 7813d86ff0ea10..f7b3561f6e0335 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -2551,7 +2551,7 @@ bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) { parseChildBlock(); break; case tok::r_paren: { - const auto *Prev = LeftParen->Previous; + auto *Prev = LeftParen->Previous; if (!MightBeStmtExpr && !MightBeFoldExpr && !Line->InMacroBody && Style.RemoveParentheses > FormatStyle::RPS_Leave) { const auto *Next = Tokens->peekNextToken(); @@ -2575,9 +2575,13 @@ bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) { FormatTok->Optional = true; } } - if (Prev && Prev->is(TT_TypenameMacro)) { -LeftParen->setFinalizedType(TT_TypeDeclarationPa
[llvm-branch-commits] [clang] [clang-format] Handle template closer followed by empty paretheses (#… (PR #111245)
https://github.com/owenca milestoned https://github.com/llvm/llvm-project/pull/111245 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [clang-format] Handle template closer followed by empty paretheses (PR #111245)
https://github.com/owenca edited https://github.com/llvm/llvm-project/pull/111245 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [clang-format] Handle template closer followed by empty paretheses (PR #111245)
https://github.com/owenca edited https://github.com/llvm/llvm-project/pull/111245 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits