Check for single smax pattern against zero when converting from a small enough float.
Details
Diff Detail
Unit Tests
Event Timeline
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | ||
---|---|---|
5139 | if (isNullOrNullSplat(N3)) ? | |
5146 | Would it be useful to have a helper method instead of this raw semanticsMaxExponent call (+ increase for the sign bit?) - canEvaluateTruncated in InstCombineCasts has a similar calculation that could use the helper as well, but that already has a comment describing what's going on. |
LGTM
llvm/include/llvm/ADT/APFloat.h | ||
---|---|---|
249 ↗ | (On Diff #492027) | Maybe add a variable name IsSigned to the bool to make it more obvious? |
I'm pretty sure this has caused a test suite failure on an SVE bot: https://lab.llvm.org/buildbot/#/builders/197/builds/3863
I'm just confirming the bisect now, but I see PerformMinMaxFpToSatCombine in the crash's backtrace.
fatal error: error in backend: Invalid size request on a scalable vector. PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: /home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1.install/bin/clang -DNDEBUG -mcpu=a64fx -mllvm -scalable-vectorization=preferred -mllvm -treat-scalable-fixed-error-as-warning=false -O3 -w -fno-strict-aliasing -ffp-contract=off -DFMA_DISABLED=1 -ffp-contract=off -DFMA_DISABLED=1 -MD -MT MultiSource/Applications/oggenc/CMakeFiles/oggenc.dir/oggenc.c.o -MF CMakeFiles/oggenc.dir/oggenc.c.o.d -o CMakeFiles/oggenc.dir/oggenc.c.o -c /home/tcwg-buildbot/worker/clang-aarch64-sve-vla/test/test-suite/MultiSource/Applications/oggenc/oggenc.c 1. <eof> parser at end of file 2. Code generation 3. Running pass 'Function Pass Manager' on module '/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/test/test-suite/MultiSource/Applications/oggenc/oggenc.c'. 4. Running pass 'AArch64 Instruction Selection' on function '@accumulate_fit' #0 0x0000aaaac079d8e0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1.install/bin/clang+0x75a48e0) #1 0x0000aaaac079bb08 llvm::sys::RunSignalHandlers() (/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1.install/bin/clang+0x75a2b08) #2 0x0000aaaac079cd8c llvm::sys::CleanupOnSignal(unsigned long) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1.install/bin/clang+0x75a3d8c) #3 0x0000aaaac070f468 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) CrashRecoveryContext.cpp:0:0 #4 0x0000aaaac070f3f8 llvm::CrashRecoveryContext::HandleExit(int) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1.install/bin/clang+0x75163f8) #5 0x0000aaaac0798360 llvm::sys::Process::Exit(int, bool) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1.install/bin/clang+0x759f360) #6 0x0000aaaabe42e830 llvm::BatchAAResults::~BatchAAResults() cc1_main.cpp:0:0 #7 0x0000aaaac0717650 llvm::report_fatal_error(llvm::Twine const&, bool) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1.install/bin/clang+0x751e650) #8 0x0000aaaac071751c (/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1.install/bin/clang+0x751e51c) #9 0x0000aaaac07568a0 llvm::TypeSize::operator unsigned long() const (/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1.install/bin/clang+0x755d8a0) #10 0x0000aaaac07568c4 llvm::TypeSize::operator unsigned long() const (/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1.install/bin/clang+0x755d8c4) #11 0x0000aaaac1748f8c PerformMinMaxFpToSatCombine(llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::ISD::CondCode, llvm::SelectionDAG&) DAGCombiner.cpp:0:0 #12 0x0000aaaac17101dc (anonymous namespace)::DAGCombiner::visitIMINMAX(llvm::SDNode*) DAGCombiner.cpp:0:0 #13 0x0000aaaac1705e18 (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) DAGCombiner.cpp:0:0 #14 0x0000aaaac1702600 llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOpt::Level) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1.install/bin/clang+0x8509600) #15 0x0000aaaac18596ac llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1.install/bin/clang+0x86606ac) #16 0x0000aaaac18583d0 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1.install/bin/clang+0x865f3d0) <...>
I'll get you the reproducer.
if (isNullOrNullSplat(N3)) ?