Skip to content

[SLP]Do not require external uses for roots and single use for other instructions in computeMinimumValueSizes. #72679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

alexey-bataev
Copy link
Member

After changes, that does not require support from InstCombine, we can
drop some extra requirements for values-to-be-demoted. No need to check
for external uses for roots/other instructions, just check that the
no non-vectorized insertelement instruction, which may require
widening.

@llvmbot
Copy link
Member

llvmbot commented Nov 17, 2023

@llvm/pr-subscribers-llvm-transforms

Author: Alexey Bataev (alexey-bataev)

Changes

After changes, that does not require support from InstCombine, we can
drop some extra requirements for values-to-be-demoted. No need to check
for external uses for roots/other instructions, just check that the
no non-vectorized insertelement instruction, which may require
widening.


Full diff: https://github.com/llvm/llvm-project/pull/72679.diff

2 Files Affected:

  • (modified) llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp (+6-8)
  • (modified) llvm/test/Transforms/SLPVectorizer/X86/root-trunc-extract-reuse.ll (+10-12)
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index bff3e49b14bc6bc..42e4540eb8ecbd7 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -13078,10 +13078,13 @@ bool BoUpSLP::collectValuesToDemote(Value *V,
     return true;
   }
 
-  // If the value is not a vectorized instruction in the expression with only
-  // one use, it cannot be demoted.
+  // If the value is not a vectorized instruction in the expression and not the
+  // used by the insertelement instruction, it cannot be demoted.
   auto *I = dyn_cast<Instruction>(V);
-  if (!I || !I->hasOneUse() || !getTreeEntry(I) || !Visited.insert(I).second)
+  if (!I || !getTreeEntry(I) || !Visited.insert(I).second ||
+      all_of(I->users(), [&](User *U) {
+        return isa<InsertElementInst>(U) && !getTreeEntry(U);
+      }))
     return false;
 
   switch (I->getOpcode()) {
@@ -13140,11 +13143,6 @@ bool BoUpSLP::collectValuesToDemote(Value *V,
 }
 
 void BoUpSLP::computeMinimumValueSizes() {
-  // If there are no external uses, the expression tree must be rooted by a
-  // store. We can't demote in-memory values, so there is nothing to do here.
-  if (ExternalUses.empty())
-    return;
-
   // We only attempt to truncate integer expressions.
   auto &TreeRoot = VectorizableTree[0]->Scalars;
   auto *TreeRootIT = dyn_cast<IntegerType>(TreeRoot[0]->getType());
diff --git a/llvm/test/Transforms/SLPVectorizer/X86/root-trunc-extract-reuse.ll b/llvm/test/Transforms/SLPVectorizer/X86/root-trunc-extract-reuse.ll
index f48528e502b8cf1..af46b4f576234b2 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/root-trunc-extract-reuse.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/root-trunc-extract-reuse.ll
@@ -8,20 +8,18 @@ define i1 @test() {
 ; CHECK:       then:
 ; CHECK-NEXT:    br label [[ELSE]]
 ; CHECK:       else:
-; CHECK-NEXT:    [[TMP0:%.*]] = phi <2 x i1> [ zeroinitializer, [[THEN]] ], [ zeroinitializer, [[ENTRY:%.*]] ]
-; CHECK-NEXT:    [[TMP1:%.*]] = zext <2 x i1> [[TMP0]] to <2 x i32>
-; CHECK-NEXT:    [[TMP2:%.*]] = extractelement <2 x i1> [[TMP0]], i32 0
-; CHECK-NEXT:    [[TMP3:%.*]] = zext i1 [[TMP2]] to i32
-; CHECK-NEXT:    [[BF_CAST162:%.*]] = and i32 [[TMP3]], 0
-; CHECK-NEXT:    [[TMP4:%.*]] = shufflevector <2 x i32> zeroinitializer, <2 x i32> [[TMP1]], <2 x i32> <i32 3, i32 1>
-; CHECK-NEXT:    [[T13:%.*]] = and <2 x i32> [[TMP4]], zeroinitializer
+; CHECK-NEXT:    [[TMP0:%.*]] = phi <2 x i32> [ zeroinitializer, [[THEN]] ], [ zeroinitializer, [[ENTRY:%.*]] ]
+; CHECK-NEXT:    [[TMP1:%.*]] = extractelement <2 x i32> [[TMP0]], i32 0
+; CHECK-NEXT:    [[BF_CAST162:%.*]] = and i32 [[TMP1]], 0
+; CHECK-NEXT:    [[TMP2:%.*]] = shufflevector <2 x i32> zeroinitializer, <2 x i32> [[TMP0]], <2 x i32> <i32 3, i32 1>
+; CHECK-NEXT:    [[T13:%.*]] = and <2 x i32> [[TMP2]], zeroinitializer
 ; CHECK-NEXT:    br label [[ELSE1:%.*]]
 ; CHECK:       else1:
-; CHECK-NEXT:    [[TMP5:%.*]] = shufflevector <2 x i32> [[T13]], <2 x i32> poison, <2 x i32> <i32 poison, i32 0>
-; CHECK-NEXT:    [[TMP6:%.*]] = insertelement <2 x i32> [[TMP5]], i32 [[BF_CAST162]], i32 0
-; CHECK-NEXT:    [[TMP7:%.*]] = icmp ugt <2 x i32> [[TMP6]], zeroinitializer
-; CHECK-NEXT:    [[TMP8:%.*]] = extractelement <2 x i1> [[TMP7]], i32 1
-; CHECK-NEXT:    ret i1 [[TMP8]]
+; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <2 x i32> [[T13]], <2 x i32> poison, <2 x i32> <i32 poison, i32 0>
+; CHECK-NEXT:    [[TMP4:%.*]] = insertelement <2 x i32> [[TMP3]], i32 [[BF_CAST162]], i32 0
+; CHECK-NEXT:    [[TMP5:%.*]] = icmp ugt <2 x i32> [[TMP4]], zeroinitializer
+; CHECK-NEXT:    [[TMP6:%.*]] = extractelement <2 x i1> [[TMP5]], i32 1
+; CHECK-NEXT:    ret i1 [[TMP6]]
 ;
 entry:
   br i1 false, label %then, label %else

@alexey-bataev alexey-bataev force-pushed the SLPImproveCollectValuesToDemote branch 3 times, most recently from 0b9adf8 to 2c9bc62 Compare November 27, 2023 13:24
@alexey-bataev
Copy link
Member Author

Ping!

@RKSimon
Copy link
Collaborator

RKSimon commented Nov 30, 2023

@alexey-bataev please can you rebase?

@alexey-bataev alexey-bataev force-pushed the SLPImproveCollectValuesToDemote branch 2 times, most recently from 1c699bc to 0a526cc Compare December 1, 2023 17:53
@alexey-bataev
Copy link
Member Author

Ping!

@alexey-bataev alexey-bataev force-pushed the SLPImproveCollectValuesToDemote branch from 0a526cc to 708edc7 Compare January 3, 2024 20:41
@alexey-bataev
Copy link
Member Author

Ping!

@alexey-bataev alexey-bataev force-pushed the SLPImproveCollectValuesToDemote branch from 708edc7 to 9f174f5 Compare January 10, 2024 15:15
Copy link
Collaborator

@RKSimon RKSimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

// If the value is not a vectorized instruction in the expression with only
// one use, it cannot be demoted.
// If the value is not a vectorized instruction in the expression and not the
// used by the insertelement instruction, it cannot be demoted.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"and not the used by the insertelement instruction" -> "and not used by the insertelement instruction"?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment correct? It still doesn't seem right.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed your comments, for some reason did not get the updates in e-mails.
Fixed this message.

; CHECK-NEXT: [[TMP0:%.*]] = call i16 @llvm.vector.reduce.or.v4i16(<4 x i16> zeroinitializer)
; CHECK-NEXT: [[TMP1:%.*]] = zext i16 [[TMP0]] to i32
; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], 65535
; CHECK-NEXT: store i32 [[TMP2]], ptr null, align 4
; CHECK-NEXT: ret void
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have better tests than these cases that will all constant fold away?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few. I'll try to improve this one.

instructions in computeMinimumValueSizes.

After changes, that does not require support from InstCombine, we can
drop some extra requirements for values-to-be-demoted. No need to check
for external uses for roots/other instructions, just check that the
  no non-vectorized insertelement instruction, which may require
  widening.
@alexey-bataev alexey-bataev force-pushed the SLPImproveCollectValuesToDemote branch from 9f174f5 to 486f4bb Compare January 10, 2024 19:06
@alexey-bataev alexey-bataev merged commit 408dce8 into llvm:main Jan 10, 2024
@alexey-bataev alexey-bataev deleted the SLPImproveCollectValuesToDemote branch January 10, 2024 19:07
@mstorsjo
Copy link
Member

mstorsjo commented Jan 11, 2024

This triggers failed asserts:

char a[];
short *b;
int c, d, e, f;
void g() {
  char *h;
  for (;;) {
    for (; f; ++f) {
      h[f] = b[0] * a[e] + b[c] * a[1] >> 7;
      ++b;
    }
    h += d;
  }
}
$ clang -target x86_64-linux-gnu -c repro.c -O2
clang: ../lib/IR/Instructions.cpp:3335: static llvm::CastInst* llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, const llvm::Twine&, llvm::Instruction*): Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' failed.

This comes up in compiling libvpx and openh264.

I'll push a revert soon.

mstorsjo added a commit that referenced this pull request Jan 11, 2024
…r other instructions in computeMinimumValueSizes. (#72679)"

This reverts commit 408dce8.

This triggered failed asserts with code like this:

    char a[];
    short *b;
    int c, d, e, f;
    void g() {
      char *h;
      for (;;) {
        for (; f; ++f) {
          h[f] = b[0] * a[e] + b[c] * a[1] >> 7;
          ++b;
        }
        h += d;
      }
    }

Compiled like this:

    $ clang -target x86_64-linux-gnu -c repro.c -O2
    clang: ../lib/IR/Instructions.cpp:3335: static llvm::CastInst* llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, const llvm::Twine&, llvm::Instruction*): Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' failed.
alexey-bataev added a commit that referenced this pull request Jan 11, 2024
…instructions in computeMinimumValueSizes. (#72679)

After changes, that does not require support from InstCombine, we can
drop some extra requirements for values-to-be-demoted. No need to check
for external uses for roots/other instructions, just check that the
  no non-vectorized insertelement instruction, which may require
  widening.

Review: #72679
@mikaelholmen
Copy link
Collaborator

Hi @alexey-bataev
The following starts crashing with this patch (also the re-applied one)

opt -passes=slp-vectorizer bbi-90943.ll -o /dev/nul

It crashes with

opt: ../lib/IR/Instructions.cpp:2956: static llvm::BinaryOperator *llvm::BinaryOperator::Create(llvm::Instruction::BinaryOps, llvm::Value *, llvm::Value *, const llvm::Twine &, llvm::Instruction *): Assertion `S1->getType() == S2->getType() && "Cannot create binary operator with two operands of differing type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: ../../main-github/llvm/build-all/bin/opt -passes=slp-vectorizer bbi-90943.ll -o /dev/null
 #0 0x00005652edde3e67 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (../../main-github/llvm/build-all/bin/opt+0x63a8e67)
 #1 0x00005652edde19be llvm::sys::RunSignalHandlers() (../../main-github/llvm/build-all/bin/opt+0x63a69be)
 #2 0x00005652edde452f SignalHandler(int) (../../main-github/llvm/build-all/bin/opt+0x63a952f)
 #3 0x00007f6c391a4630 __restore_rt (/lib64/libpthread.so.0+0xf630)
 #4 0x00007f6c368eb387 raise (/lib64/libc.so.6+0x36387)
 #5 0x00007f6c368eca78 abort (/lib64/libc.so.6+0x37a78)
 #6 0x00007f6c368e41a6 __assert_fail_base (/lib64/libc.so.6+0x2f1a6)
 #7 0x00007f6c368e4252 (/lib64/libc.so.6+0x2f252)
 #8 0x00005652ed7b39e0 llvm::BinaryOperator::Create(llvm::Instruction::BinaryOps, llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*) (../../main-github/llvm/build-all/bin/opt+0x5d789e0)
 #9 0x00005652ee4d11a0 (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) (../../main-github/llvm/build-all/bin/opt+0x6a961a0)
#10 0x00005652ee4b4f18 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (../../main-github/llvm/build-all/bin/opt+0x6a79f18)
#11 0x00005652ee4e0250 bool llvm::SLPVectorizerPass::vectorizeCmpInsts<std::reverse_iterator<llvm::CmpInst* const*> >(llvm::iterator_range<std::reverse_iterator<llvm::CmpInst* const*> >, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (../../main-github/llvm/build-all/bin/opt+0x6aa5250)
#12 0x00005652ee4b6917 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&)::$_146::operator()(bool) const (../../main-github/llvm/build-all/bin/opt+0x6a7b917)
#13 0x00005652ee4abf76 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (../../main-github/llvm/build-all/bin/opt+0x6a70f76)
#14 0x00005652ee4a98d0 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (../../main-github/llvm/build-all/bin/opt+0x6a6e8d0)
#15 0x00005652ee4a8e51 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x6a6de51)
#16 0x00005652edffb7fd llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x65c07fd)
#17 0x00005652ed815634 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x5dda634)
#18 0x00005652ebbcbe3d llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x4190e3d)
#19 0x00005652ed819a1e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x5ddea1e)
#20 0x00005652ebbcbbdd llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x4190bdd)
#21 0x00005652ed814756 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x5dd9756)
#22 0x00005652eb6e3d43 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (../../main-github/llvm/build-all/bin/opt+0x3ca8d43)
#23 0x00005652eb6f2444 main (../../main-github/llvm/build-all/bin/opt+0x3cb7444)
#24 0x00007f6c368d7555 __libc_start_main (/lib64/libc.so.6+0x22555)
#25 0x00005652eb6ddee9 _start (../../main-github/llvm/build-all/bin/opt+0x3ca2ee9)
Abort (core dumped)

bbi-90943.ll.gz

@alexey-bataev
Copy link
Member Author

Hi @alexey-bataev The following starts crashing with this patch (also the re-applied one)

opt -passes=slp-vectorizer bbi-90943.ll -o /dev/nul

It crashes with

opt: ../lib/IR/Instructions.cpp:2956: static llvm::BinaryOperator *llvm::BinaryOperator::Create(llvm::Instruction::BinaryOps, llvm::Value *, llvm::Value *, const llvm::Twine &, llvm::Instruction *): Assertion `S1->getType() == S2->getType() && "Cannot create binary operator with two operands of differing type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: ../../main-github/llvm/build-all/bin/opt -passes=slp-vectorizer bbi-90943.ll -o /dev/null
 #0 0x00005652edde3e67 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (../../main-github/llvm/build-all/bin/opt+0x63a8e67)
 #1 0x00005652edde19be llvm::sys::RunSignalHandlers() (../../main-github/llvm/build-all/bin/opt+0x63a69be)
 #2 0x00005652edde452f SignalHandler(int) (../../main-github/llvm/build-all/bin/opt+0x63a952f)
 #3 0x00007f6c391a4630 __restore_rt (/lib64/libpthread.so.0+0xf630)
 #4 0x00007f6c368eb387 raise (/lib64/libc.so.6+0x36387)
 #5 0x00007f6c368eca78 abort (/lib64/libc.so.6+0x37a78)
 #6 0x00007f6c368e41a6 __assert_fail_base (/lib64/libc.so.6+0x2f1a6)
 #7 0x00007f6c368e4252 (/lib64/libc.so.6+0x2f252)
 #8 0x00005652ed7b39e0 llvm::BinaryOperator::Create(llvm::Instruction::BinaryOps, llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::BasicBlock*) (../../main-github/llvm/build-all/bin/opt+0x5d789e0)
 #9 0x00005652ee4d11a0 (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) (../../main-github/llvm/build-all/bin/opt+0x6a961a0)
#10 0x00005652ee4b4f18 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (../../main-github/llvm/build-all/bin/opt+0x6a79f18)
#11 0x00005652ee4e0250 bool llvm::SLPVectorizerPass::vectorizeCmpInsts<std::reverse_iterator<llvm::CmpInst* const*> >(llvm::iterator_range<std::reverse_iterator<llvm::CmpInst* const*> >, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (../../main-github/llvm/build-all/bin/opt+0x6aa5250)
#12 0x00005652ee4b6917 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&)::$_146::operator()(bool) const (../../main-github/llvm/build-all/bin/opt+0x6a7b917)
#13 0x00005652ee4abf76 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (../../main-github/llvm/build-all/bin/opt+0x6a70f76)
#14 0x00005652ee4a98d0 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (../../main-github/llvm/build-all/bin/opt+0x6a6e8d0)
#15 0x00005652ee4a8e51 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x6a6de51)
#16 0x00005652edffb7fd llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x65c07fd)
#17 0x00005652ed815634 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x5dda634)
#18 0x00005652ebbcbe3d llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x4190e3d)
#19 0x00005652ed819a1e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x5ddea1e)
#20 0x00005652ebbcbbdd llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x4190bdd)
#21 0x00005652ed814756 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x5dd9756)
#22 0x00005652eb6e3d43 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (../../main-github/llvm/build-all/bin/opt+0x3ca8d43)
#23 0x00005652eb6f2444 main (../../main-github/llvm/build-all/bin/opt+0x3cb7444)
#24 0x00007f6c368d7555 __libc_start_main (/lib64/libc.so.6+0x22555)
#25 0x00005652eb6ddee9 _start (../../main-github/llvm/build-all/bin/opt+0x3ca2ee9)
Abort (core dumped)

bbi-90943.ll.gz

Thanks, will fix it ASAP

@alexey-bataev
Copy link
Member Author

Fixed in 39b2104

@mikaelholmen
Copy link
Collaborator

Fixed in 39b2104

Thanks!

justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
…instructions in computeMinimumValueSizes. (llvm#72679)

After changes, that does not require support from InstCombine, we can
drop some extra requirements for values-to-be-demoted. No need to check
for external uses for roots/other instructions, just check that the
  no non-vectorized insertelement instruction, which may require
  widening.
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
…r other instructions in computeMinimumValueSizes. (llvm#72679)"

This reverts commit 408dce8.

This triggered failed asserts with code like this:

    char a[];
    short *b;
    int c, d, e, f;
    void g() {
      char *h;
      for (;;) {
        for (; f; ++f) {
          h[f] = b[0] * a[e] + b[c] * a[1] >> 7;
          ++b;
        }
        h += d;
      }
    }

Compiled like this:

    $ clang -target x86_64-linux-gnu -c repro.c -O2
    clang: ../lib/IR/Instructions.cpp:3335: static llvm::CastInst* llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, const llvm::Twine&, llvm::Instruction*): Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' failed.
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
…instructions in computeMinimumValueSizes. (llvm#72679)

After changes, that does not require support from InstCombine, we can
drop some extra requirements for values-to-be-demoted. No need to check
for external uses for roots/other instructions, just check that the
  no non-vectorized insertelement instruction, which may require
  widening.

Review: llvm#72679
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants