[llvm] [ConstantFolding] Handle large exponents in ldexp (PR #199309)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sat May 23 11:47:20 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: 9d533e977eea1e1c0ee94515bc5dd0bd70d15d95 -->
<!-- llvm-hackme-head-sha: bf4ec17189f466734e48e0cb6cb842004057a610 -->
<!-- llvm-hackme-patch-sha256: 37682eb8563c7d37981f4674b37531dbb7e88bba83dd2d548c7badc1ca725b4e -->
<!-- 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.
## Reproducer
**Kind**: crash
**IR Reproducer**:
```llvm
; RUN: opt -passes=instcombine<no-verify-fixpoint> -S
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
define float @f() {
%r = call float @llvm.ldexp.f32.i8(float 1.0, i8 1)
ret float %r
}
```
**Stacktrace**:
```
opt: ../llvm-project-pr/llvm/lib/Support/APInt.cpp:1006: llvm::APInt llvm::APInt::truncSSat(unsigned int) const: Assertion `width <= BitWidth && "Invalid APInt Truncate request"' failed.
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/tmp7ru9brzl.ll -passes=instcombine<no-verify-fixpoint>
1. Running pass "function(instcombine<max-iterations=1;no-verify-fixpoint>)" on module "/tmp/tmp7ru9brzl.ll"
2. Running pass "instcombine<max-iterations=1;no-verify-fixpoint>" 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.23.0git 0x00007ffff7e11462 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 66
1 libLLVMSupport.so.23.0git 0x00007ffff7e0df3c llvm::sys::RunSignalHandlers() + 76
2 libLLVMSupport.so.23.0git 0x00007ffff7e0e141
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 libc.so.6 0x00007ffff79ff71b
8 libc.so.6 0x00007ffff7a10e96
9 libLLVMSupport.so.23.0git 0x00007ffff7cbbcdb llvm::APInt::truncSSat(unsigned int) const + 491
10 libLLVMAnalysis.so.23.0git 0x00007fffee5b9e1e
11 libLLVMAnalysis.so.23.0git 0x00007fffee5c3396 llvm::ConstantFoldCall(llvm::CallBase const*, llvm::Function*, llvm::ArrayRef<llvm::Constant*>, llvm::TargetLibraryInfo const*, bool) + 1558
12 libLLVMAnalysis.so.23.0git 0x00007fffee5c6e0f llvm::ConstantFoldInstruction(llvm::Instruction const*, llvm::DataLayout const&, llvm::TargetLibraryInfo const*) + 943
13 libLLVMInstCombine.so.23.0git 0x00007fffef26103b
14 libLLVMInstCombine.so.23.0git 0x00007fffef267728
15 libLLVMInstCombine.so.23.0git 0x00007fffef26862f llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) + 1967
16 libLLVMPasses.so.23.0git 0x00007ffff14fc9e6
17 libLLVMCore.so.23.0git 0x00007fffee0f486d llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) + 381
18 libLLVMAMDGPUCodeGen.so.23.0git 0x00007ffff58d7166
19 libLLVMCore.so.23.0git 0x00007fffee0f4d07 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 439
20 libLLVMOptDriver.so.23.0git 0x00007ffff7f849c6
21 libLLVMCore.so.23.0git 0x00007fffee0f1fef llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 319
22 libLLVMOptDriver.so.23.0git 0x00007ffff7f91064 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) + 4612
23 libLLVMOptDriver.so.23.0git 0x00007ffff7f9edec optMain + 15900
24 libc.so.6 0x00007ffff7a00d90
25 libc.so.6 0x00007ffff7a00e40 __libc_start_main + 128
26 opt 0x0000555555555095 _start + 37
```
**Baseline Revision**: `9d533e977eea1e1c0ee94515bc5dd0bd70d15d95`
**PR Head SHA**: `bf4ec17189f466734e48e0cb6cb842004057a610`
**Patch SHA256**: `37682eb8563c7d37981f4674b37531dbb7e88bba83dd2d548c7badc1ca725b4e`
https://github.com/llvm/llvm-project/pull/199309
More information about the llvm-commits
mailing list