llvm-project
070b1933 - [GlobalISel] Make m_OneUse ignore debug uses; remove m_OneNonDBGUse (#237070)

Commit
2 days ago
[GlobalISel] Make m_OneUse ignore debug uses; remove m_OneNonDBGUse (#237070) The Machine IR `m_OneUse` matcher currently counts `DBG_VALUE` uses. A debug-only use can therefore block any combine that requires one ordinary use and make generated code depend on `-g`. In `matchCtls`, for example, this AArch64 GlobalISel input emits one `cls` instruction with `-g0`, but `eor`/`clz`/`sub` with `-g`: ```c int cls_add(int x) { int sign = x >> 31; int flipped = x ^ sign; return __builtin_clz(flipped) - 1; } ``` This patch defines `m_OneUse` in terms of `hasOneNonDBGUse`, removes the redundant `m_OneNonDBGUse` matcher, and updates its callers. No in-tree Machine IR matcher needs the old including-debug semantics; the separate IR pattern matcher used by `IRTranslator` is unchanged. Besides `matchCtls`, the semantic change covers `matchSimplifyNegMinMax` and the AMDGPU pack instruction selection matchers. Existing `m_OneNonDBGUse` callers retain their behavior under the shorter name. Direct calls to `MRI.hasOneUse()` are outside this patch because several require coordinated iterator or debug-location handling. The existing matcher unit test now checks both one ordinary use plus debug uses and a value used only by debug instructions. The `matchCtls` regression covers both supported `G_CTLS` forms and fails without the semantic change. This issue was found by a non-AI automated testing tool. AI assisted with the analysis and development of the fix.
Author
Parents
Loading