[clang] [llvm] [SPIRV] add pre legalization instruction combine (PR #122839)
Farzon Lotfi via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 17 06:30:08 PST 2025
================
@@ -0,0 +1,140 @@
+; RUN: llc -mtriple=spirv-unknown-unknown -debug-pass=Structure < %s -o /dev/null 2>&1 | \
----------------
farzonl wrote:
I'm using this test case to help me figure out why I'm seeing an assert fire in `SPV_INTEL_inline_assembly/inline_asm.ll`. I can remove it before I take this PR out of draft. TLDR on the investigation there is an assert firing in `llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp` The pass before mine had an inline assembly that is some how removed by my pass.
pass before:
```bash
/mnt/DevDrive/projects/llvm_debug_build/bin/llc -stop-after=irtranslator -global-isel \
-verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown \
llvm/test/CodeGen/SPIRV/extensions/SPV_INTEL_inline_assembly/inline_asm.ll \
--spirv-ext=+SPV_INTEL_inline_assembly -o -
```
Inline assembly removed:
```asm
%71:_(s64) = G_ANYEXT %68(s32)
%70:iid = COPY %71(s64)
%72:fid = COPY %69(s64)
INLINEASM &"constcmd $0 $1", 0 /* attdialect */, 327689 /* reguse:iID */, %70, 262153 /* reguse:fID */, %72
```
pass after:
```
/mnt/DevDrive/projects/llvm_debug_build/bin/llc -stop-after=spirv-prelegalizer-combiner -global-isel \
-verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown \
llvm/test/CodeGen/SPIRV/extensions/SPV_INTEL_inline_assembly/inline_asm.ll \
--spirv-ext=+SPV_INTEL_inline_assembly -o -
```
MIR diff
![image](https://github.com/user-attachments/assets/7feb8896-effc-4ce8-9787-6ccac09e96cf)
I've tried removing the CSE analysis pass but something else in `SPIRVPreLegalizerCombiner` is removing the inline assembly.
![image](https://github.com/user-attachments/assets/a48b55b5-775f-45d0-8cc4-c02589ca12d7)
https://github.com/llvm/llvm-project/pull/122839
More information about the llvm-commits
mailing list