This is an archive of the discontinued LLVM Phabricator instance.

[X86] Transform vector SET{LE/ULT/ULE} -> SETLT and SET{GE/UGT/UGE} -> SETGT if possible
ClosedPublic

Authored by goldstein.w.n on Jan 20 2023, 1:40 PM.

Details

Summary

SETLT and SETGT can use {v}pcmpgt directly whereas the other SETCC
variants require some other instructions as well. On AVX512, which has
vector comparisons for all SETCC variants, this can still be
preferable if the destination is a vector. And if the destination is a
mask, its the same performance.

The transform for unsigned SETCC takes place if we know from
KnownBits that LHS/RHS have the same sign.

The transform for LE/GE -> LT/GT takes place if LHS/RHS is constant
and we can inc/dec all elements in the operand without overflowing
(both signed and unsigned).

Alive2 Links (on i8 so they don't timeout):
sge_s: https://alive2.llvm.org/ce/z/rMPt9_
sge_s_2: https://alive2.llvm.org/ce/z/G74Mhs
sge_u: https://alive2.llvm.org/ce/z/PTWARM
sge_u_2: https://alive2.llvm.org/ce/z/L9dsNn
sgt_s: https://alive2.llvm.org/ce/z/q2CHEK
sgt_u: https://alive2.llvm.org/ce/z/YPLnZ8
sle_s: https://alive2.llvm.org/ce/z/HyYhQ_
sle_s_2: https://alive2.llvm.org/ce/z/ck6NkT
sle_u: https://alive2.llvm.org/ce/z/tyF_wN
sle_u_2: https://alive2.llvm.org/ce/z/et8t98
slt_s: https://alive2.llvm.org/ce/z/oCP43b
slt_u: https://alive2.llvm.org/ce/z/EpLLPx
uge_s: https://alive2.llvm.org/ce/z/rqSDwi
uge_s_2: https://alive2.llvm.org/ce/z/67UTXu
uge_u: https://alive2.llvm.org/ce/z/yBNG9C
uge_u_2: https://alive2.llvm.org/ce/z/UhHYc_
ugt_s: https://alive2.llvm.org/ce/z/tY9va4
ugt_u: https://alive2.llvm.org/ce/z/F9zeAT
ule_s: https://alive2.llvm.org/ce/z/1MNgka
ule_s_2: https://alive2.llvm.org/ce/z/oiS7Ls
ule_u: https://alive2.llvm.org/ce/z/8DveC3
ule_u_2: https://alive2.llvm.org/ce/z/jGp2M7
ult_s: https://alive2.llvm.org/ce/z/chzfwP
ult_u: https://alive2.llvm.org/ce/z/Jj_JYu

Diff Detail

Event Timeline

goldstein.w.n created this revision.Jan 20 2023, 1:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 20 2023, 1:40 PM
goldstein.w.n requested review of this revision.Jan 20 2023, 1:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 20 2023, 1:40 PM

Cleanup some style nits

This feels like we could easily make this a generic DAG fold with a suitable TLI callback to help determine the preferred CondCode (or just signed/unsigned).

This feels like we could easily make this a generic DAG fold with a suitable TLI callback to help determine the preferred CondCode (or just signed/unsigned).

What where you thinking the API would be? I can see it being easy to represent "prefered signed/unsigned" but have trouble seeing a clean and generic
API for only if LT/GT but NOT for LE/GE.

This feels like we could easily make this a generic DAG fold with a suitable TLI callback to help determine the preferred CondCode (or just signed/unsigned).

What where you thinking the API would be? I can see it being easy to represent "prefered signed/unsigned" but have trouble seeing a clean and generic
API for only if LT/GT but NOT for LE/GE.

Sounds like the hook should just take the current CC and return the preferred one?

Are there other targets that have such a strong preference for a specific vector condition code?

This feels like we could easily make this a generic DAG fold with a suitable TLI callback to help determine the preferred CondCode (or just signed/unsigned).

What where you thinking the API would be? I can see it being easy to represent "prefered signed/unsigned" but have trouble seeing a clean and generic
API for only if LT/GT but NOT for LE/GE.

Sounds like the hook should just take the current CC and return the preferred one?

Sure but I'm not sure how you would write it w.o expanding every case ( {sources} X {targets} ) which I'm not sure would be clean.
Signed/unsigned wouldn't be too hard, but that could end up de-optimizing b.c something like sle is less useful than ule for analysis
and on something like x86 has no codegen benefit.

Maybe you could get away with 4x combinations of PreferSigned X PreferWithEq

Are there other targets that have such a strong preference for a specific vector condition code?

Not that I know of but can't say I'm an expert outside of x86.

This feels like we could easily make this a generic DAG fold with a suitable TLI callback to help determine the preferred CondCode (or just signed/unsigned).

We would need 2x TLI callback (for x86 at least) b.c of the truncateAVX512SetCCNoBWI that can be required.

Are there any other arch that have preferences about which SETCC variant is used? If so I'm in favor of moving,
otherwise personally don't see the need, but what is the opinion of the room?

This feels like we could easily make this a generic DAG fold with a suitable TLI callback to help determine the preferred CondCode (or just signed/unsigned).

We would need 2x TLI callback (for x86 at least) b.c of the truncateAVX512SetCCNoBWI that can be required.

Are there any other arch that have preferences about which SETCC variant is used? If so I'm in favor of moving,
otherwise personally don't see the need, but what is the opinion of the room?

@RKSimon thoughts?

This feels like we could easily make this a generic DAG fold with a suitable TLI callback to help determine the preferred CondCode (or just signed/unsigned).

We would need 2x TLI callback (for x86 at least) b.c of the truncateAVX512SetCCNoBWI that can be required.

Are there any other arch that have preferences about which SETCC variant is used? If so I'm in favor of moving,
otherwise personally don't see the need, but what is the opinion of the room?

@RKSimon thoughts?

@RKSimon ping.

This feels like we could easily make this a generic DAG fold with a suitable TLI callback to help determine the preferred CondCode (or just signed/unsigned).

We would need 2x TLI callback (for x86 at least) b.c of the truncateAVX512SetCCNoBWI that can be required.

Are there any other arch that have preferences about which SETCC variant is used? If so I'm in favor of moving,
otherwise personally don't see the need, but what is the opinion of the room?

@RKSimon thoughts?

@RKSimon ping.

ping @RKSimon

Sorry - I kept missing this - just a couple of minors.

For some reason I thought there were more targets with limited condcodes.

llvm/lib/Target/X86/X86ISelLowering.cpp
53906

This NOTE mentions a count check - but there isn't one?

54061

Why not just OpVT.isInteger()?

goldstein.w.n added inline comments.Feb 11 2023, 10:57 AM
llvm/lib/Target/X86/X86ISelLowering.cpp
53906

I'm not sure, I just copied verbatim over from L53380 in the original when factoring it out into a function.

goldstein.w.n marked an inline comment as done.Feb 11 2023, 2:19 PM

Cleanup OpVT checks

RKSimon accepted this revision.Feb 12 2023, 3:51 AM

LGTM - maybe remove that element count note in a followup nfc?

This revision is now accepted and ready to land.Feb 12 2023, 3:51 AM
saugustine added a subscriber: saugustine.EditedFeb 15 2023, 1:45 PM

I have tracked an obscure failure down to this change. Still working on getting a reproducer suitable for public consumption, but the stack trace is below. It does go right through several of the places this commit touched.

 #0 0x000055df400bd2fa llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:567:11
 #1 0x000055df400bd4ab PrintStackTraceSignalHandler(void*) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:641:1
 #2 0x000055df400bba16 llvm::sys::RunSignalHandlers() /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Signals.cpp:104:5
 #3 0x000055df400bcb6e llvm::sys::CleanupOnSignal(unsigned long) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:367:1
 #4 0x000055df3fffece4 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:0:7
 #5 0x000055df3ffff0a2 CrashRecoverySignalHandler(int) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:391:1
 #6 0x00007f7e1b25af90 (/lib/x86_64-linux-gnu/libc.so.6+0x3bf90)
 #7 0x00007f7e1b2a9ccc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #8 0x00007f7e1b25aef2 raise ./signal/../sysdeps/posix/raise.c:27:6
 #9 0x00007f7e1b245472 abort ./stdlib/abort.c:81:7
#10 0x00007f7e1b245395 _nl_load_domain ./intl/loadmsgcat.c:1177:9
#11 0x00007f7e1b253df2 (/lib/x86_64-linux-gnu/libc.so.6+0x34df2)
#12 0x000055df3e20e5cc llvm::EVT::getSimpleVT() const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/CodeGen/ValueTypes.h:0:7
#13 0x000055df3e351fb5 llvm::SDValue::getSimpleValueType() const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/CodeGen/SelectionDAGNodes.h:191:27
#14 0x000055df3e49d6db incDecVectorConstant(llvm::SDValue, llvm::SelectionDAG&, bool, bool) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:24734:14
#15 0x000055df3e47a27a combineSetCC(llvm::SDNode*, llvm::SelectionDAG&, llvm::TargetLowering::DAGCombinerInfo&, llvm::X86Subtarget const&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:54098:35
#16 0x000055df3e45241e llvm::X86TargetLowering::PerformDAGCombine(llvm::SDNode*, llvm::TargetLowering::DAGCombinerInfo&) const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:56987:36
#17 0x000055df4196019f (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:2000:16
#18 0x000055df4195f6a6 (anonymous namespace)::DAGCombiner::Run(llvm::CombineLevel) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1781:18
#19 0x000055df4195ef8f llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOpt::Level) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:26965:3
#20 0x000055df41bb190f llvm::SelectionDAGISel::CodeGenAndEmitDAG() /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:784:3
#21 0x000055df41bb14bd llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, bool&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:700:1
#22 0x000055df41bb0f4e llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1638:11
#23 0x000055df41bae480 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:480:3
#24 0x000055df3e31ef0a (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:192:7
#25 0x000055df3edc9495 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:91:8
#26 0x000055df3f6673c6 llvm::FPPassManager::runOnFunction(llvm::Function&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1430:23
#27 0x000055df3f66c1f2 llvm::FPPassManager::runOnModule(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1476:16
#28 0x000055df3f667c99 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1545:23
#29 0x000055df3f66780d llvm::legacy::PassManagerImpl::run(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:535:16
#30 0x000055df3f66c4d1 llvm::legacy::PassManager::run(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1672:3
#31 0x000055df41dc95b3 codegen(llvm::lto::Config const&, llvm::TargetMachine*, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex const&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/LTO/LTOBackend.cpp:417:7
#32 0x000055df41dca05d llvm::lto::thinBackend(llvm::lto::Config const&, unsigned int, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, llvm::Module&, llvm::ModuleSummaryIndex const&, llvm::StringMap<std::unordered_set<unsigned long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<unsigned long>>, llvm::MallocAllocator> const&, llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned long, void>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*>> const&, llvm::MapVector<llvm::StringRef, llvm::BitcodeModule, llvm::DenseMap<llvm::StringRef, unsigned int, llvm::DenseMapInfo<llvm::StringRef, void>, llvm::detail::DenseMapPair<llvm::StringRef, unsigned int>>, std::vector<std::pair<llvm::StringRef, llvm::BitcodeModule>, std::allocator<std::pair<llvm::StringRef, llvm::BitcodeModule>>>>*, std::vector<unsigned char, std::allocator<unsigned char>> const&)::$_6::operator()(llvm::Module&, llvm::TargetMachine*, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>) const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/LTO/LTOBackend.cpp:586:9
#33 0x000055df41dc9f26 llvm::lto::thinBackend(llvm::lto::Config const&, unsigned int, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, llvm::Module&, llvm::ModuleSummaryIndex const&, llvm::StringMap<std::unordered_set<unsigned long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<unsigned long>>, llvm::MallocAllocator> const&, llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned long, void>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*>> const&, llvm::MapVector<llvm::StringRef, llvm::BitcodeModule, llvm::DenseMap<llvm::StringRef, unsigned int, llvm::DenseMapInfo<llvm::StringRef, void>, llvm::detail::DenseMapPair<llvm::StringRef, unsigned int>>, std::vector<std::pair<llvm::StringRef, llvm::BitcodeModule>, std::allocator<std::pair<llvm::StringRef, llvm::BitcodeModule>>>>*, std::vector<unsigned char, std::allocator<unsigned char>> const&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/LTO/LTOBackend.cpp:657:3
#34 0x000055df4065fc60 runThinLTOBackend(clang::DiagnosticsEngine&, llvm::ModuleSummaryIndex*, llvm::Module*, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, clang::BackendAction) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1202:11
#35 0x000055df4065f2cb clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1243:9
#36 0x000055df41d50630 clang::CodeGenAction::ExecuteAction() /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1242:3
#37 0x000055df412a424c clang::FrontendAction::Execute() /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1062:7
#38 0x000055df411cd518 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1049:23
#39 0x000055df4146b927 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:264:8
#40 0x000055df3e1982d0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/cc1_main.cpp:251:13
#41 0x000055df3e182ffa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/driver.cpp:363:5
#42 0x000055df3e184c4d clang_main(int, char**, llvm::ToolContext const&)::$_1::operator()(llvm::SmallVectorImpl<char const*>&) const /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/driver.cpp:541:7
#43 0x000055df3e184c1d int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::$_1>(long, llvm::SmallVectorImpl<char const*>&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:5
#44 0x000055df41083e89 llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::operator()(llvm::SmallVectorImpl<char const*>&) const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:5
#45 0x000055df41080328 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_1::operator()() const /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Driver/Job.cpp:439:34
#46 0x000055df410802f5 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_1>(long) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:5
#47 0x000055df3eacc6d9 llvm::function_ref<void ()>::operator()() const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:5
#48 0x000055df3fffeafa llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:427:3
#49 0x000055df4107fa87 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Driver/Job.cpp:439:7
#50 0x000055df4101cbaf clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Driver/Compilation.cpp:199:15
#51 0x000055df4101cdb7 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Driver/Compilation.cpp:253:13
#52 0x000055df41037298 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Driver/Driver.cpp:1856:7
#53 0x000055df3e182a79 clang_main(int, char**, llvm::ToolContext const&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/driver.cpp:577:9
#54 0x000055df3e1ba67d main /usr/local/google/home/saugustine/llvm/build/tools/clang/tools/driver/clang-driver.cpp:15:3
#55 0x00007f7e1b24618a __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#56 0x00007f7e1b246245 call_init ./csu/../csu/libc-start.c:128:20
#57 0x00007f7e1b246245 __libc_start_main ./csu/../csu/libc-start.c:368:5
#58 0x000055df3e181451 _start (/usr/local/google/home/saugustine/llvm/build/bin/clang+0x1b2a451)

I have tracked an obscure failure down to this change. Still working on getting a reproducer suitable for public consumption, but the stack trace is below. It does go right through several of the places this commit touched.

 #0 0x000055df400bd2fa llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:567:11
 #1 0x000055df400bd4ab PrintStackTraceSignalHandler(void*) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:641:1
 #2 0x000055df400bba16 llvm::sys::RunSignalHandlers() /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Signals.cpp:104:5
 #3 0x000055df400bcb6e llvm::sys::CleanupOnSignal(unsigned long) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:367:1
 #4 0x000055df3fffece4 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:0:7
 #5 0x000055df3ffff0a2 CrashRecoverySignalHandler(int) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:391:1
 #6 0x00007f7e1b25af90 (/lib/x86_64-linux-gnu/libc.so.6+0x3bf90)
 #7 0x00007f7e1b2a9ccc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #8 0x00007f7e1b25aef2 raise ./signal/../sysdeps/posix/raise.c:27:6
 #9 0x00007f7e1b245472 abort ./stdlib/abort.c:81:7
#10 0x00007f7e1b245395 _nl_load_domain ./intl/loadmsgcat.c:1177:9
#11 0x00007f7e1b253df2 (/lib/x86_64-linux-gnu/libc.so.6+0x34df2)
#12 0x000055df3e20e5cc llvm::EVT::getSimpleVT() const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/CodeGen/ValueTypes.h:0:7
#13 0x000055df3e351fb5 llvm::SDValue::getSimpleValueType() const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/CodeGen/SelectionDAGNodes.h:191:27
#14 0x000055df3e49d6db incDecVectorConstant(llvm::SDValue, llvm::SelectionDAG&, bool, bool) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:24734:14
#15 0x000055df3e47a27a combineSetCC(llvm::SDNode*, llvm::SelectionDAG&, llvm::TargetLowering::DAGCombinerInfo&, llvm::X86Subtarget const&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:54098:35
#16 0x000055df3e45241e llvm::X86TargetLowering::PerformDAGCombine(llvm::SDNode*, llvm::TargetLowering::DAGCombinerInfo&) const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:56987:36
#17 0x000055df4196019f (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:2000:16
#18 0x000055df4195f6a6 (anonymous namespace)::DAGCombiner::Run(llvm::CombineLevel) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1781:18
#19 0x000055df4195ef8f llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOpt::Level) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:26965:3
#20 0x000055df41bb190f llvm::SelectionDAGISel::CodeGenAndEmitDAG() /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:784:3
#21 0x000055df41bb14bd llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, bool&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:700:1
#22 0x000055df41bb0f4e llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1638:11
#23 0x000055df41bae480 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:480:3
#24 0x000055df3e31ef0a (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:192:7
#25 0x000055df3edc9495 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:91:8
#26 0x000055df3f6673c6 llvm::FPPassManager::runOnFunction(llvm::Function&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1430:23
#27 0x000055df3f66c1f2 llvm::FPPassManager::runOnModule(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1476:16
#28 0x000055df3f667c99 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1545:23
#29 0x000055df3f66780d llvm::legacy::PassManagerImpl::run(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:535:16
#30 0x000055df3f66c4d1 llvm::legacy::PassManager::run(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1672:3
#31 0x000055df41dc95b3 codegen(llvm::lto::Config const&, llvm::TargetMachine*, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex const&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/LTO/LTOBackend.cpp:417:7
#32 0x000055df41dca05d llvm::lto::thinBackend(llvm::lto::Config const&, unsigned int, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, llvm::Module&, llvm::ModuleSummaryIndex const&, llvm::StringMap<std::unordered_set<unsigned long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<unsigned long>>, llvm::MallocAllocator> const&, llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned long, void>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*>> const&, llvm::MapVector<llvm::StringRef, llvm::BitcodeModule, llvm::DenseMap<llvm::StringRef, unsigned int, llvm::DenseMapInfo<llvm::StringRef, void>, llvm::detail::DenseMapPair<llvm::StringRef, unsigned int>>, std::vector<std::pair<llvm::StringRef, llvm::BitcodeModule>, std::allocator<std::pair<llvm::StringRef, llvm::BitcodeModule>>>>*, std::vector<unsigned char, std::allocator<unsigned char>> const&)::$_6::operator()(llvm::Module&, llvm::TargetMachine*, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>) const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/LTO/LTOBackend.cpp:586:9
#33 0x000055df41dc9f26 llvm::lto::thinBackend(llvm::lto::Config const&, unsigned int, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, llvm::Module&, llvm::ModuleSummaryIndex const&, llvm::StringMap<std::unordered_set<unsigned long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<unsigned long>>, llvm::MallocAllocator> const&, llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned long, void>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*>> const&, llvm::MapVector<llvm::StringRef, llvm::BitcodeModule, llvm::DenseMap<llvm::StringRef, unsigned int, llvm::DenseMapInfo<llvm::StringRef, void>, llvm::detail::DenseMapPair<llvm::StringRef, unsigned int>>, std::vector<std::pair<llvm::StringRef, llvm::BitcodeModule>, std::allocator<std::pair<llvm::StringRef, llvm::BitcodeModule>>>>*, std::vector<unsigned char, std::allocator<unsigned char>> const&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/LTO/LTOBackend.cpp:657:3
#34 0x000055df4065fc60 runThinLTOBackend(clang::DiagnosticsEngine&, llvm::ModuleSummaryIndex*, llvm::Module*, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, clang::BackendAction) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1202:11
#35 0x000055df4065f2cb clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1243:9
#36 0x000055df41d50630 clang::CodeGenAction::ExecuteAction() /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1242:3
#37 0x000055df412a424c clang::FrontendAction::Execute() /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1062:7
#38 0x000055df411cd518 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1049:23
#39 0x000055df4146b927 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:264:8
#40 0x000055df3e1982d0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/cc1_main.cpp:251:13
#41 0x000055df3e182ffa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/driver.cpp:363:5
#42 0x000055df3e184c4d clang_main(int, char**, llvm::ToolContext const&)::$_1::operator()(llvm::SmallVectorImpl<char const*>&) const /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/driver.cpp:541:7
#43 0x000055df3e184c1d int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::$_1>(long, llvm::SmallVectorImpl<char const*>&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:5
#44 0x000055df41083e89 llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::operator()(llvm::SmallVectorImpl<char const*>&) const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:5
#45 0x000055df41080328 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_1::operator()() const /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Driver/Job.cpp:439:34
#46 0x000055df410802f5 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_1>(long) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:5
#47 0x000055df3eacc6d9 llvm::function_ref<void ()>::operator()() const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:5
#48 0x000055df3fffeafa llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:427:3
#49 0x000055df4107fa87 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Driver/Job.cpp:439:7
#50 0x000055df4101cbaf clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Driver/Compilation.cpp:199:15
#51 0x000055df4101cdb7 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Driver/Compilation.cpp:253:13
#52 0x000055df41037298 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Driver/Driver.cpp:1856:7
#53 0x000055df3e182a79 clang_main(int, char**, llvm::ToolContext const&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/driver.cpp:577:9
#54 0x000055df3e1ba67d main /usr/local/google/home/saugustine/llvm/build/tools/clang/tools/driver/clang-driver.cpp:15:3
#55 0x00007f7e1b24618a __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#56 0x00007f7e1b246245 call_init ./csu/../csu/libc-start.c:128:20
#57 0x00007f7e1b246245 __libc_start_main ./csu/../csu/libc-start.c:368:5
#58 0x000055df3e181451 _start (/usr/local/google/home/saugustine/llvm/build/bin/clang+0x1b2a451)

I suspect we're calling incDecVectorConstant from combineSetCC for an illegal type so it isn't an MVT. It's an EVT.

I have tracked an obscure failure down to this change. Still working on getting a reproducer suitable for public consumption, but the stack trace is below. It does go right through several of the places this commit touched.

 #0 0x000055df400bd2fa llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:567:11
 #1 0x000055df400bd4ab PrintStackTraceSignalHandler(void*) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:641:1
 #2 0x000055df400bba16 llvm::sys::RunSignalHandlers() /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Signals.cpp:104:5
 #3 0x000055df400bcb6e llvm::sys::CleanupOnSignal(unsigned long) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:367:1
 #4 0x000055df3fffece4 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:0:7
 #5 0x000055df3ffff0a2 CrashRecoverySignalHandler(int) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:391:1
 #6 0x00007f7e1b25af90 (/lib/x86_64-linux-gnu/libc.so.6+0x3bf90)
 #7 0x00007f7e1b2a9ccc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #8 0x00007f7e1b25aef2 raise ./signal/../sysdeps/posix/raise.c:27:6
 #9 0x00007f7e1b245472 abort ./stdlib/abort.c:81:7
#10 0x00007f7e1b245395 _nl_load_domain ./intl/loadmsgcat.c:1177:9
#11 0x00007f7e1b253df2 (/lib/x86_64-linux-gnu/libc.so.6+0x34df2)
#12 0x000055df3e20e5cc llvm::EVT::getSimpleVT() const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/CodeGen/ValueTypes.h:0:7
#13 0x000055df3e351fb5 llvm::SDValue::getSimpleValueType() const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/CodeGen/SelectionDAGNodes.h:191:27
#14 0x000055df3e49d6db incDecVectorConstant(llvm::SDValue, llvm::SelectionDAG&, bool, bool) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:24734:14
#15 0x000055df3e47a27a combineSetCC(llvm::SDNode*, llvm::SelectionDAG&, llvm::TargetLowering::DAGCombinerInfo&, llvm::X86Subtarget const&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:54098:35
#16 0x000055df3e45241e llvm::X86TargetLowering::PerformDAGCombine(llvm::SDNode*, llvm::TargetLowering::DAGCombinerInfo&) const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:56987:36
#17 0x000055df4196019f (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:2000:16
#18 0x000055df4195f6a6 (anonymous namespace)::DAGCombiner::Run(llvm::CombineLevel) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1781:18
#19 0x000055df4195ef8f llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOpt::Level) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:26965:3
#20 0x000055df41bb190f llvm::SelectionDAGISel::CodeGenAndEmitDAG() /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:784:3
#21 0x000055df41bb14bd llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, bool&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:700:1
#22 0x000055df41bb0f4e llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1638:11
#23 0x000055df41bae480 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:480:3
#24 0x000055df3e31ef0a (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:192:7
#25 0x000055df3edc9495 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:91:8
#26 0x000055df3f6673c6 llvm::FPPassManager::runOnFunction(llvm::Function&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1430:23
#27 0x000055df3f66c1f2 llvm::FPPassManager::runOnModule(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1476:16
#28 0x000055df3f667c99 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1545:23
#29 0x000055df3f66780d llvm::legacy::PassManagerImpl::run(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:535:16
#30 0x000055df3f66c4d1 llvm::legacy::PassManager::run(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1672:3
#31 0x000055df41dc95b3 codegen(llvm::lto::Config const&, llvm::TargetMachine*, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex const&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/LTO/LTOBackend.cpp:417:7
#32 0x000055df41dca05d llvm::lto::thinBackend(llvm::lto::Config const&, unsigned int, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, llvm::Module&, llvm::ModuleSummaryIndex const&, llvm::StringMap<std::unordered_set<unsigned long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<unsigned long>>, llvm::MallocAllocator> const&, llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned long, void>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*>> const&, llvm::MapVector<llvm::StringRef, llvm::BitcodeModule, llvm::DenseMap<llvm::StringRef, unsigned int, llvm::DenseMapInfo<llvm::StringRef, void>, llvm::detail::DenseMapPair<llvm::StringRef, unsigned int>>, std::vector<std::pair<llvm::StringRef, llvm::BitcodeModule>, std::allocator<std::pair<llvm::StringRef, llvm::BitcodeModule>>>>*, std::vector<unsigned char, std::allocator<unsigned char>> const&)::$_6::operator()(llvm::Module&, llvm::TargetMachine*, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>) const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/LTO/LTOBackend.cpp:586:9
#33 0x000055df41dc9f26 llvm::lto::thinBackend(llvm::lto::Config const&, unsigned int, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, llvm::Module&, llvm::ModuleSummaryIndex const&, llvm::StringMap<std::unordered_set<unsigned long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<unsigned long>>, llvm::MallocAllocator> const&, llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned long, void>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*>> const&, llvm::MapVector<llvm::StringRef, llvm::BitcodeModule, llvm::DenseMap<llvm::StringRef, unsigned int, llvm::DenseMapInfo<llvm::StringRef, void>, llvm::detail::DenseMapPair<llvm::StringRef, unsigned int>>, std::vector<std::pair<llvm::StringRef, llvm::BitcodeModule>, std::allocator<std::pair<llvm::StringRef, llvm::BitcodeModule>>>>*, std::vector<unsigned char, std::allocator<unsigned char>> const&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/LTO/LTOBackend.cpp:657:3
#34 0x000055df4065fc60 runThinLTOBackend(clang::DiagnosticsEngine&, llvm::ModuleSummaryIndex*, llvm::Module*, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, clang::BackendAction) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1202:11
#35 0x000055df4065f2cb clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1243:9
#36 0x000055df41d50630 clang::CodeGenAction::ExecuteAction() /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1242:3
#37 0x000055df412a424c clang::FrontendAction::Execute() /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1062:7
#38 0x000055df411cd518 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1049:23
#39 0x000055df4146b927 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:264:8
#40 0x000055df3e1982d0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/cc1_main.cpp:251:13
#41 0x000055df3e182ffa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/driver.cpp:363:5
#42 0x000055df3e184c4d clang_main(int, char**, llvm::ToolContext const&)::$_1::operator()(llvm::SmallVectorImpl<char const*>&) const /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/driver.cpp:541:7
#43 0x000055df3e184c1d int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::$_1>(long, llvm::SmallVectorImpl<char const*>&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:5
#44 0x000055df41083e89 llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::operator()(llvm::SmallVectorImpl<char const*>&) const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:5
#45 0x000055df41080328 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_1::operator()() const /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Driver/Job.cpp:439:34
#46 0x000055df410802f5 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_1>(long) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:5
#47 0x000055df3eacc6d9 llvm::function_ref<void ()>::operator()() const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:5
#48 0x000055df3fffeafa llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:427:3
#49 0x000055df4107fa87 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Driver/Job.cpp:439:7
#50 0x000055df4101cbaf clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Driver/Compilation.cpp:199:15
#51 0x000055df4101cdb7 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Driver/Compilation.cpp:253:13
#52 0x000055df41037298 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Driver/Driver.cpp:1856:7
#53 0x000055df3e182a79 clang_main(int, char**, llvm::ToolContext const&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/driver.cpp:577:9
#54 0x000055df3e1ba67d main /usr/local/google/home/saugustine/llvm/build/tools/clang/tools/driver/clang-driver.cpp:15:3
#55 0x00007f7e1b24618a __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#56 0x00007f7e1b246245 call_init ./csu/../csu/libc-start.c:128:20
#57 0x00007f7e1b246245 __libc_start_main ./csu/../csu/libc-start.c:368:5
#58 0x000055df3e181451 _start (/usr/local/google/home/saugustine/llvm/build/bin/clang+0x1b2a451)

I suspect we're calling incDecVectorConstant from combineSetCC for an illegal type so it isn't an MVT. It's an EVT.

Its currently guarded by: if (VT.isVector() && OpVT.isVector() && OpVT.isInteger())
What would be the proper check?

Will revert shortly (just testing real fast that it doesn't conflict with anything).

I think it probably needs to also check if the type is Simple, because the exact assertion that fails is isSimple.

And if I insert a check for isSimple on line 24731, the test does pass.

if (!BV || !V.getValueType().isSimple())

Not sure if that is the correct fix, but perhaps better than reverting. The test case is huge and buried.

I think it probably needs to also check if the type is Simple, because the exact assertion that fails is isSimple.

And if I insert a check for isSimple on line 24731, the test does pass.

if (!BV || !V.getValueType().isSimple())

Not sure if that is the correct fix, but perhaps better than reverting. The test case is huge and buried.

If you think you will able to isolate a test case, I'd say revert then resubmit with test case.

If you don't think thats feasible I'd say adding the isSimple check makes sense.

@craig.topper what do you think?

I think it probably needs to also check if the type is Simple, because the exact assertion that fails is isSimple.

And if I insert a check for isSimple on line 24731, the test does pass.

if (!BV || !V.getValueType().isSimple())

Not sure if that is the correct fix, but perhaps better than reverting. The test case is huge and buried.

Reverted for now and reposted with your fix.

goldstein.w.n reopened this revision.Feb 15 2023, 2:44 PM
This revision is now accepted and ready to land.Feb 15 2023, 2:44 PM

Fix missing check for value type in IncDecVectorConstant

I think it probably needs to also check if the type is Simple, because the exact assertion that fails is isSimple.

And if I insert a check for isSimple on line 24731, the test does pass.

if (!BV || !V.getValueType().isSimple())

Not sure if that is the correct fix, but perhaps better than reverting. The test case is huge and buried.

Are you going to be able to confirm that fix works? Or is it too complicated to reproduce?

saugustine accepted this revision.Feb 15 2023, 3:35 PM

The fix does work. But I'm still trying to get a reproducer for the future.

Incidentally, the function comment explicitly says "or this is not a simple vector constant", and yet originally didn't check for it actually being simple. With the updated fix it does.

So I think this is correct.

I think it probably needs to also check if the type is Simple, because the exact assertion that fails is isSimple.

And if I insert a check for isSimple on line 24731, the test does pass.

if (!BV || !V.getValueType().isSimple())

Not sure if that is the correct fix, but perhaps better than reverting. The test case is huge and buried.

Are you going to be able to confirm that fix works? Or is it too complicated to reproduce?

The fix does work. But I'm still trying to get a reproducer for the future.

Incidentally, the function comment explicitly says "or this is not a simple vector constant", and yet originally didn't check for it actually being simple. With the updated fix it does.

So I think this is correct.

Okay, I'll wait a bit to commit incase anyone else wants to weigh in.
Thanks for the report + fix + testing.

I think it probably needs to also check if the type is Simple, because the exact assertion that fails is isSimple.

And if I insert a check for isSimple on line 24731, the test does pass.

if (!BV || !V.getValueType().isSimple())

Not sure if that is the correct fix, but perhaps better than reverting. The test case is huge and buried.

Are you going to be able to confirm that fix works? Or is it too complicated to reproduce?

This isn't the best reproducer, but it's as small as bugpoint can make it. Worth turning into a real test?

./build/bin/clang -O3 reduced.ll

should give the failure. It does need to have assertions on.

This isn't the best reproducer, but it's as small as bugpoint can make it. Worth turning into a real test?

./build/bin/clang -O3 reduced.ll

should give the failure. It does need to have assertions on.

I don't see any vectors in that test...

I don't see any vectors in that test...

The failing stack trace is slightly different, but it still goes through incDecVectorConstant, and would be guarded by the earlier fix:

1.	Code generation
2.	Running pass 'Function Pass Manager' on module 'reduced.ll'.
3.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@failing'
 #0 0x000055e7138c52fa llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:567:11
 #1 0x000055e7138c54ab PrintStackTraceSignalHandler(void*) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:641:1
 #2 0x000055e7138c3a16 llvm::sys::RunSignalHandlers() /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Signals.cpp:104:5
 #3 0x000055e7138c5cc5 SignalHandler(int) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:412:1
 #4 0x00007ff5bee5af90 (/lib/x86_64-linux-gnu/libc.so.6+0x3bf90)
 #5 0x00007ff5beea9ccc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #6 0x00007ff5bee5aef2 raise ./signal/../sysdeps/posix/raise.c:27:6
 #7 0x00007ff5bee45472 abort ./stdlib/abort.c:81:7
 #8 0x00007ff5bee45395 _nl_load_domain ./intl/loadmsgcat.c:1177:9
 #9 0x00007ff5bee53df2 (/lib/x86_64-linux-gnu/libc.so.6+0x34df2)
#10 0x000055e711a165cc llvm::EVT::getSimpleVT() const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/CodeGen/ValueTypes.h:0:7
#11 0x000055e711b59fb5 llvm::SDValue::getSimpleValueType() const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/CodeGen/SelectionDAGNodes.h:191:27
#12 0x000055e711ca56db incDecVectorConstant(llvm::SDValue, llvm::SelectionDAG&, bool, bool) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:24734:14
#13 0x000055e711c8227a combineSetCC(llvm::SDNode*, llvm::SelectionDAG&, llvm::TargetLowering::DAGCombinerInfo&, llvm::X86Subtarget const&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:54098:35
#14 0x000055e711c5a41e llvm::X86TargetLowering::PerformDAGCombine(llvm::SDNode*, llvm::TargetLowering::DAGCombinerInfo&) const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:56987:36
#15 0x000055e71516819f (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:2000:16
#16 0x000055e7151676a6 (anonymous namespace)::DAGCombiner::Run(llvm::CombineLevel) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1781:18
#17 0x000055e715166f8f llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOpt::Level) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:26965:3
#18 0x000055e7153b990f llvm::SelectionDAGISel::CodeGenAndEmitDAG() /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:784:3
#19 0x000055e7153b94bd llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, bool&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:700:1
#20 0x000055e7153b8f4e llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1638:11
#21 0x000055e7153b6480 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:480:3
#22 0x000055e711b26f0a (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:192:7
#23 0x000055e7125d1495 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:91:8
#24 0x000055e712e6f3c6 llvm::FPPassManager::runOnFunction(llvm::Function&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1430:23
#25 0x000055e712e741f2 llvm::FPPassManager::runOnModule(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1476:16
#26 0x000055e712e6fc99 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1545:23
#27 0x000055e712e6f80d llvm::legacy::PassManagerImpl::run(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:535:16
#28 0x000055e712e744d1 llvm::legacy::PassManager::run(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1672:3
#29 0x000055e713e6db6a (anonymous namespace)::EmitAssemblyHelper::RunCodegenPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1079:3
#30 0x000055e713e67fd2 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1102:7
#31 0x000055e713e67497 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1261:3
#32 0x000055e715558630 clang::CodeGenAction::ExecuteAction() /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1242:3
#33 0x000055e714aac24c clang::FrontendAction::Execute() /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1062:7
#34 0x000055e7149d5518 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1049:23
#35 0x000055e714c73927 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:264:8
#36 0x000055e7119a02d0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/cc1_main.cpp:251:13
#37 0x000055e71198affa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/driver.cpp:363:5
#38 0x000055e711989cdd clang_main(int, char**, llvm::ToolContext const&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/driver.cpp:441:5
#39 0x000055e7119c267d main /usr/local/google/home/saugustine/llvm/build/tools/clang/tools/driver/clang-driver.cpp:15:3
#40 0x00007ff5bee4618a __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#41 0x00007ff5bee46245 call_init ./csu/../csu/libc-start.c:128:20
#42 0x00007ff5bee46245 __libc_start_main ./csu/../csu/libc-start.c:368:5
#43 0x000055e711989451 _start (/usr/local/google/home/saugustine/llvm/build/bin/clang-16+0x1b2a451)

This isn't the best reproducer, but it's as small as bugpoint can make it. Worth turning into a real test?

./build/bin/clang -O3 reduced.ll

should give the failure. It does need to have assertions on.

Seems reasonable to add as a test. @craig.topper any objection?

I don't see any vectors in that test...

The failing stack trace is slightly different, but it still goes through incDecVectorConstant, and would be guarded by the earlier fix:

1.	Code generation
2.	Running pass 'Function Pass Manager' on module 'reduced.ll'.
3.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@failing'
 #0 0x000055e7138c52fa llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:567:11
 #1 0x000055e7138c54ab PrintStackTraceSignalHandler(void*) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:641:1
 #2 0x000055e7138c3a16 llvm::sys::RunSignalHandlers() /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Signals.cpp:104:5
 #3 0x000055e7138c5cc5 SignalHandler(int) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:412:1
 #4 0x00007ff5bee5af90 (/lib/x86_64-linux-gnu/libc.so.6+0x3bf90)
 #5 0x00007ff5beea9ccc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #6 0x00007ff5bee5aef2 raise ./signal/../sysdeps/posix/raise.c:27:6
 #7 0x00007ff5bee45472 abort ./stdlib/abort.c:81:7
 #8 0x00007ff5bee45395 _nl_load_domain ./intl/loadmsgcat.c:1177:9
 #9 0x00007ff5bee53df2 (/lib/x86_64-linux-gnu/libc.so.6+0x34df2)
#10 0x000055e711a165cc llvm::EVT::getSimpleVT() const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/CodeGen/ValueTypes.h:0:7
#11 0x000055e711b59fb5 llvm::SDValue::getSimpleValueType() const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/CodeGen/SelectionDAGNodes.h:191:27
#12 0x000055e711ca56db incDecVectorConstant(llvm::SDValue, llvm::SelectionDAG&, bool, bool) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:24734:14
#13 0x000055e711c8227a combineSetCC(llvm::SDNode*, llvm::SelectionDAG&, llvm::TargetLowering::DAGCombinerInfo&, llvm::X86Subtarget const&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:54098:35
#14 0x000055e711c5a41e llvm::X86TargetLowering::PerformDAGCombine(llvm::SDNode*, llvm::TargetLowering::DAGCombinerInfo&) const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:56987:36
#15 0x000055e71516819f (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:2000:16
#16 0x000055e7151676a6 (anonymous namespace)::DAGCombiner::Run(llvm::CombineLevel) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1781:18
#17 0x000055e715166f8f llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOpt::Level) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:26965:3
#18 0x000055e7153b990f llvm::SelectionDAGISel::CodeGenAndEmitDAG() /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:784:3
#19 0x000055e7153b94bd llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, bool&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:700:1
#20 0x000055e7153b8f4e llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1638:11
#21 0x000055e7153b6480 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:480:3
#22 0x000055e711b26f0a (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:192:7
#23 0x000055e7125d1495 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:91:8
#24 0x000055e712e6f3c6 llvm::FPPassManager::runOnFunction(llvm::Function&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1430:23
#25 0x000055e712e741f2 llvm::FPPassManager::runOnModule(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1476:16
#26 0x000055e712e6fc99 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1545:23
#27 0x000055e712e6f80d llvm::legacy::PassManagerImpl::run(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:535:16
#28 0x000055e712e744d1 llvm::legacy::PassManager::run(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1672:3
#29 0x000055e713e6db6a (anonymous namespace)::EmitAssemblyHelper::RunCodegenPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1079:3
#30 0x000055e713e67fd2 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1102:7
#31 0x000055e713e67497 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1261:3
#32 0x000055e715558630 clang::CodeGenAction::ExecuteAction() /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1242:3
#33 0x000055e714aac24c clang::FrontendAction::Execute() /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1062:7
#34 0x000055e7149d5518 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1049:23
#35 0x000055e714c73927 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:264:8
#36 0x000055e7119a02d0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/cc1_main.cpp:251:13
#37 0x000055e71198affa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/driver.cpp:363:5
#38 0x000055e711989cdd clang_main(int, char**, llvm::ToolContext const&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/driver.cpp:441:5
#39 0x000055e7119c267d main /usr/local/google/home/saugustine/llvm/build/tools/clang/tools/driver/clang-driver.cpp:15:3
#40 0x00007ff5bee4618a __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#41 0x00007ff5bee46245 call_init ./csu/../csu/libc-start.c:128:20
#42 0x00007ff5bee46245 __libc_start_main ./csu/../csu/libc-start.c:368:5
#43 0x000055e711989451 _start (/usr/local/google/home/saugustine/llvm/build/bin/clang-16+0x1b2a451)

Oh I missed that the test needs to go through the middle end optimizer which vectorizes to 2xi128. So we'll need to use the output of the middle end as the test case for llc.

I don't see any vectors in that test...

The failing stack trace is slightly different, but it still goes through incDecVectorConstant, and would be guarded by the earlier fix:

1.	Code generation
2.	Running pass 'Function Pass Manager' on module 'reduced.ll'.
3.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@failing'
 #0 0x000055e7138c52fa llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:567:11
 #1 0x000055e7138c54ab PrintStackTraceSignalHandler(void*) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:641:1
 #2 0x000055e7138c3a16 llvm::sys::RunSignalHandlers() /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Signals.cpp:104:5
 #3 0x000055e7138c5cc5 SignalHandler(int) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:412:1
 #4 0x00007ff5bee5af90 (/lib/x86_64-linux-gnu/libc.so.6+0x3bf90)
 #5 0x00007ff5beea9ccc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #6 0x00007ff5bee5aef2 raise ./signal/../sysdeps/posix/raise.c:27:6
 #7 0x00007ff5bee45472 abort ./stdlib/abort.c:81:7
 #8 0x00007ff5bee45395 _nl_load_domain ./intl/loadmsgcat.c:1177:9
 #9 0x00007ff5bee53df2 (/lib/x86_64-linux-gnu/libc.so.6+0x34df2)
#10 0x000055e711a165cc llvm::EVT::getSimpleVT() const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/CodeGen/ValueTypes.h:0:7
#11 0x000055e711b59fb5 llvm::SDValue::getSimpleValueType() const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/CodeGen/SelectionDAGNodes.h:191:27
#12 0x000055e711ca56db incDecVectorConstant(llvm::SDValue, llvm::SelectionDAG&, bool, bool) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:24734:14
#13 0x000055e711c8227a combineSetCC(llvm::SDNode*, llvm::SelectionDAG&, llvm::TargetLowering::DAGCombinerInfo&, llvm::X86Subtarget const&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:54098:35
#14 0x000055e711c5a41e llvm::X86TargetLowering::PerformDAGCombine(llvm::SDNode*, llvm::TargetLowering::DAGCombinerInfo&) const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:56987:36
#15 0x000055e71516819f (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:2000:16
#16 0x000055e7151676a6 (anonymous namespace)::DAGCombiner::Run(llvm::CombineLevel) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1781:18
#17 0x000055e715166f8f llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOpt::Level) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:26965:3
#18 0x000055e7153b990f llvm::SelectionDAGISel::CodeGenAndEmitDAG() /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:784:3
#19 0x000055e7153b94bd llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, bool&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:700:1
#20 0x000055e7153b8f4e llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1638:11
#21 0x000055e7153b6480 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:480:3
#22 0x000055e711b26f0a (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:192:7
#23 0x000055e7125d1495 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:91:8
#24 0x000055e712e6f3c6 llvm::FPPassManager::runOnFunction(llvm::Function&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1430:23
#25 0x000055e712e741f2 llvm::FPPassManager::runOnModule(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1476:16
#26 0x000055e712e6fc99 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1545:23
#27 0x000055e712e6f80d llvm::legacy::PassManagerImpl::run(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:535:16
#28 0x000055e712e744d1 llvm::legacy::PassManager::run(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1672:3
#29 0x000055e713e6db6a (anonymous namespace)::EmitAssemblyHelper::RunCodegenPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1079:3
#30 0x000055e713e67fd2 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1102:7
#31 0x000055e713e67497 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1261:3
#32 0x000055e715558630 clang::CodeGenAction::ExecuteAction() /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1242:3
#33 0x000055e714aac24c clang::FrontendAction::Execute() /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1062:7
#34 0x000055e7149d5518 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1049:23
#35 0x000055e714c73927 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:264:8
#36 0x000055e7119a02d0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/cc1_main.cpp:251:13
#37 0x000055e71198affa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/driver.cpp:363:5
#38 0x000055e711989cdd clang_main(int, char**, llvm::ToolContext const&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/driver.cpp:441:5
#39 0x000055e7119c267d main /usr/local/google/home/saugustine/llvm/build/tools/clang/tools/driver/clang-driver.cpp:15:3
#40 0x00007ff5bee4618a __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#41 0x00007ff5bee46245 call_init ./csu/../csu/libc-start.c:128:20
#42 0x00007ff5bee46245 __libc_start_main ./csu/../csu/libc-start.c:368:5
#43 0x000055e711989451 _start (/usr/local/google/home/saugustine/llvm/build/bin/clang-16+0x1b2a451)

Oh I missed that the test needs to go through the middle end optimizer which vectorizes to 2xi128. So we'll need to use the output of the middle end as the test case for llc.

where does that happen? I dont see any vectors: https://godbolt.org/z/TEdExxvao

I don't see any vectors in that test...

The failing stack trace is slightly different, but it still goes through incDecVectorConstant, and would be guarded by the earlier fix:

1.	Code generation
2.	Running pass 'Function Pass Manager' on module 'reduced.ll'.
3.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@failing'
 #0 0x000055e7138c52fa llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:567:11
 #1 0x000055e7138c54ab PrintStackTraceSignalHandler(void*) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:641:1
 #2 0x000055e7138c3a16 llvm::sys::RunSignalHandlers() /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Signals.cpp:104:5
 #3 0x000055e7138c5cc5 SignalHandler(int) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:412:1
 #4 0x00007ff5bee5af90 (/lib/x86_64-linux-gnu/libc.so.6+0x3bf90)
 #5 0x00007ff5beea9ccc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #6 0x00007ff5bee5aef2 raise ./signal/../sysdeps/posix/raise.c:27:6
 #7 0x00007ff5bee45472 abort ./stdlib/abort.c:81:7
 #8 0x00007ff5bee45395 _nl_load_domain ./intl/loadmsgcat.c:1177:9
 #9 0x00007ff5bee53df2 (/lib/x86_64-linux-gnu/libc.so.6+0x34df2)
#10 0x000055e711a165cc llvm::EVT::getSimpleVT() const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/CodeGen/ValueTypes.h:0:7
#11 0x000055e711b59fb5 llvm::SDValue::getSimpleValueType() const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/include/llvm/CodeGen/SelectionDAGNodes.h:191:27
#12 0x000055e711ca56db incDecVectorConstant(llvm::SDValue, llvm::SelectionDAG&, bool, bool) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:24734:14
#13 0x000055e711c8227a combineSetCC(llvm::SDNode*, llvm::SelectionDAG&, llvm::TargetLowering::DAGCombinerInfo&, llvm::X86Subtarget const&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:54098:35
#14 0x000055e711c5a41e llvm::X86TargetLowering::PerformDAGCombine(llvm::SDNode*, llvm::TargetLowering::DAGCombinerInfo&) const /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:56987:36
#15 0x000055e71516819f (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:2000:16
#16 0x000055e7151676a6 (anonymous namespace)::DAGCombiner::Run(llvm::CombineLevel) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1781:18
#17 0x000055e715166f8f llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOpt::Level) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:26965:3
#18 0x000055e7153b990f llvm::SelectionDAGISel::CodeGenAndEmitDAG() /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:784:3
#19 0x000055e7153b94bd llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, bool&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:700:1
#20 0x000055e7153b8f4e llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1638:11
#21 0x000055e7153b6480 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:480:3
#22 0x000055e711b26f0a (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:192:7
#23 0x000055e7125d1495 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:91:8
#24 0x000055e712e6f3c6 llvm::FPPassManager::runOnFunction(llvm::Function&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1430:23
#25 0x000055e712e741f2 llvm::FPPassManager::runOnModule(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1476:16
#26 0x000055e712e6fc99 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1545:23
#27 0x000055e712e6f80d llvm::legacy::PassManagerImpl::run(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:535:16
#28 0x000055e712e744d1 llvm::legacy::PassManager::run(llvm::Module&) /usr/local/google/home/saugustine/llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1672:3
#29 0x000055e713e6db6a (anonymous namespace)::EmitAssemblyHelper::RunCodegenPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1079:3
#30 0x000055e713e67fd2 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1102:7
#31 0x000055e713e67497 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1261:3
#32 0x000055e715558630 clang::CodeGenAction::ExecuteAction() /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1242:3
#33 0x000055e714aac24c clang::FrontendAction::Execute() /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1062:7
#34 0x000055e7149d5518 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1049:23
#35 0x000055e714c73927 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /usr/local/google/home/saugustine/llvm/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:264:8
#36 0x000055e7119a02d0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/cc1_main.cpp:251:13
#37 0x000055e71198affa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/driver.cpp:363:5
#38 0x000055e711989cdd clang_main(int, char**, llvm::ToolContext const&) /usr/local/google/home/saugustine/llvm/llvm-project/clang/tools/driver/driver.cpp:441:5
#39 0x000055e7119c267d main /usr/local/google/home/saugustine/llvm/build/tools/clang/tools/driver/clang-driver.cpp:15:3
#40 0x00007ff5bee4618a __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#41 0x00007ff5bee46245 call_init ./csu/../csu/libc-start.c:128:20
#42 0x00007ff5bee46245 __libc_start_main ./csu/../csu/libc-start.c:368:5
#43 0x000055e711989451 _start (/usr/local/google/home/saugustine/llvm/build/bin/clang-16+0x1b2a451)

Oh I missed that the test needs to go through the middle end optimizer which vectorizes to 2xi128. So we'll need to use the output of the middle end as the test case for llc.

where does that happen? I dont see any vectors: https://godbolt.org/z/TEdExxvao

Not sure. It happens with clang instead of opt https://godbolt.org/z/saYYosG1x

This isn't the best reproducer, but it's as small as bugpoint can make it. Worth turning into a real test?

./build/bin/clang -O3 reduced.ll

should give the failure. It does need to have assertions on.

Seems reasonable to add as a test. @craig.topper any objection?

Added this (after running through middle end) as a new test attached to the recommit, will push shortly.

This revision was landed with ongoing or failed builds.Feb 16 2023, 6:40 PM
This revision was automatically updated to reflect the committed changes.