llvm-project
6aaeed06 - [LoongArch] Ignore debug uses when folding large offsets (#230290)

Commit
26 days ago
[LoongArch] Ignore debug uses when folding large offsets (#230290) A `DBG_VALUE` can currently make `foldLargeOffset` reject an otherwise foldable offset because the pass uses `hasOneUse()`. As a result, equivalent MIR with and without debug information can produce different instruction sequences. Use `hasOneNonDBGUse()` for the profitability check. Since the fold erases the offset-producing instructions, mark their debug users undef before erasing them. The new MIR test covers the case where a large offset has one ordinary use and one debug use. Without the change, the offset remains materialized with `LU12I_W` and `ADD_W`; with the change, it is folded into `PCADDU12I` and `ADDI_W`, and the invalidated `DBG_VALUE` uses `$noreg`. The checks were generated with `utils/update_mir_test_checks.py`. Tests: `check-llvm-codegen-loongarch` (958 passed), `git clang-format --diff HEAD`, and `git diff --check`. Assisted-by: OpenAI Codex 5.6 Sol, co-reviewed by Claude and Yongqiang Tian.
Author
Parents
Loading