[llvm] [VectorCombine] fold fptoui(fdiv(uitofp(x),uitofp(y))) into udiv(x,y) (PR #214844)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 14 08:37:50 PDT 2026


dtcxzyw wrote:

The following correctness issue was found by [llvm-hackme](https://github.com/dtcxzyw/llvm-hackme).

<!-- llvm-hackme-state: bug_found -->
<!-- llvm-hackme-baseline: 81ac5c7c26efb70ffaffb91b26053437093ee085 -->
<!-- llvm-hackme-head-sha: 5899994e860016dfdbb74ed31c0a7512ca68a02d -->
<!-- llvm-hackme-patch-sha256: 05877358ca6946b723765046c6fd3b5067a3f26d31b8041bfa1ec863eaa2d81a -->
<!-- llvm-hackme-kind: crash -->

This comment is generated by an automated correctness checking service designed to help identify critical correctness bugs (opt crashes or Alive2 miscompilations) and improve PR review efficiency under limited reviewer bandwidth.

The reproducer was generated by LLM.

This bug is a regression introduced by this PR. It does not reproduce on the baseline commit.

## Reproducer

**Kind**: crash

**IR Reproducer**:
```llvm
; RUN: opt -passes=vector-combine -S
target triple = "x86_64-unknown-linux-gnu"
define <vscale x 4 x i32> @f() {
  %a = uitofp <vscale x 4 x i32> splat (i32 7) to <vscale x 4 x double>
  %b = uitofp <vscale x 4 x i32> splat (i32 2) to <vscale x 4 x double>
  %r = fdiv <vscale x 4 x double> %a, %b
  %res = fptoui <vscale x 4 x double> %r to <vscale x 4 x i32>
  ret <vscale x 4 x i32> %res
}
```

**Stacktrace**:
```
LLVM ERROR: Possible incorrect use of MVT::getVectorNumElements() for scalable vector. Scalable flag may be dropped, use MVT::getVectorElementCount() instead
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: /llvm-hackme/work/llvm-hackme/llvm-build-pr/bin/opt -S -o /dev/null /tmp/tmpt51dyd6k.ll -passes=vector-combine
1.	Running pass "function(vector-combine)" on module "/tmp/tmpt51dyd6k.ll"
2.	Running pass "vector-combine" on function "f"
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  libLLVMSupport.so.24.0git    0x00007ffff7e1a882 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 66
1  libLLVMSupport.so.24.0git    0x00007ffff7e174bc llvm::sys::RunSignalHandlers() + 76
2  libLLVMSupport.so.24.0git    0x00007ffff7e176c5
3  libc.so.6                    0x00007ffff7a19520
4  libc.so.6                    0x00007ffff7a6d9fc pthread_kill + 300
5  libc.so.6                    0x00007ffff7a19476 raise + 22
6  libc.so.6                    0x00007ffff79ff7f3 abort + 211
7  libLLVMSupport.so.24.0git    0x00007ffff7c76a58
8  libLLVMSupport.so.24.0git    0x00007ffff7d1d745
9  libLLVMSupport.so.24.0git    0x00007ffff7d1d784
10 libLLVMX86CodeGen.so.24.0git 0x00007ffff35dcd46
11 libLLVMX86CodeGen.so.24.0git 0x00007ffff38611fb llvm::X86TTIImpl::getArithmeticInstrCost(unsigned int, llvm::Type*, llvm::TargetTransformInfo::TargetCostKind, llvm::TargetTransformInfo::OperandValueInfo, llvm::TargetTransformInfo::OperandValueInfo, llvm::ArrayRef<llvm::Value const*>, llvm::Instruction const*) const + 7579
12 libLLVMAnalysis.so.24.0git   0x00007fffee696094 llvm::TargetTransformInfo::getArithmeticInstrCost(unsigned int, llvm::Type*, llvm::TargetTransformInfo::TargetCostKind, llvm::TargetTransformInfo::OperandValueInfo, llvm::TargetTransformInfo::OperandValueInfo, llvm::ArrayRef<llvm::Value const*>, llvm::Instruction const*, llvm::TargetLibraryInfo const*) const + 340
13 libLLVMVectorize.so.24.0git  0x00007ffff0913072
14 libLLVMVectorize.so.24.0git  0x00007ffff09389ab
15 libLLVMVectorize.so.24.0git  0x00007ffff093ad39 llvm::VectorCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) + 1817
16 libLLVMPasses.so.24.0git     0x00007ffff145e726
17 libLLVMCore.so.24.0git       0x00007fffedd0473e llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) + 910
18 libLLVMPasses.so.24.0git     0x00007ffff145c4c6
19 libLLVMCore.so.24.0git       0x00007fffedd035f7 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 1271
20 libLLVMPasses.so.24.0git     0x00007ffff145fe56
21 libLLVMCore.so.24.0git       0x00007fffedd02eef llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 911
22 libLLVMOptDriver.so.24.0git  0x00007ffff7f94874 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) + 6196
23 libLLVMOptDriver.so.24.0git  0x00007ffff7fa18c4 optMain + 12468
24 libc.so.6                    0x00007ffff7a00d90
25 libc.so.6                    0x00007ffff7a00e40 __libc_start_main + 128
26 opt                          0x0000555555555095 _start + 37
```


**Baseline Revision**: `81ac5c7c26efb70ffaffb91b26053437093ee085`
**PR Head SHA**: `5899994e860016dfdbb74ed31c0a7512ca68a02d`
**Patch SHA256**: `05877358ca6946b723765046c6fd3b5067a3f26d31b8041bfa1ec863eaa2d81a`


https://github.com/llvm/llvm-project/pull/214844


More information about the llvm-commits mailing list