Skip to content

SPIRV: Set NoPHIs property after rewriting them #136327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 24, 2025

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Apr 18, 2025

There should be no PHIs after selection, as OpPhi is used
instead. This hopefully avoids errors in #135277.

Copy link
Contributor Author

arsenm commented Apr 18, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@llvmbot
Copy link
Member

llvmbot commented Apr 18, 2025

@llvm/pr-subscribers-backend-spir-v

Author: Matt Arsenault (arsenm)

Changes

There should be no PHIs after selection, as OpPhi is used
instead. This hopefully avoids errors in #135277.


Full diff: https://github.com/llvm/llvm-project/pull/136327.diff

1 Files Affected:

  • (modified) llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp (+6)
diff --git a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
index 68286737b972f..f30578767a939 100644
--- a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
@@ -269,6 +269,12 @@ class SPIRVInstructionSelect : public InstructionSelect {
     return InstructionSelect::getRequiredProperties().reset(
         MachineFunctionProperties::Property::RegBankSelected);
   }
+
+  MachineFunctionProperties getClearedProperties() const override {
+    // No generic Phis remain, replaced with OpPhi
+    return InstructionSelect::getClearedProperties().reset(
+        MachineFunctionProperties::Property::NoPHIs);
+  }
 };
 } // namespace
 

@arsenm arsenm marked this pull request as ready for review April 18, 2025 17:13
@mikhailramalho
Copy link
Member

The errors mentioned in PR #135277 still happen if we apply the patch here without 1293477:

Failed Tests (15):
  LLVM :: CodeGen/AArch64/fast-isel-cmp-vec.ll
  LLVM :: CodeGen/AArch64/wineh4.mir
  LLVM :: CodeGen/AArch64/wineh8.mir
  LLVM :: CodeGen/SPIRV/assume.ll
  LLVM :: CodeGen/SPIRV/expect.ll
  LLVM :: CodeGen/SPIRV/hlsl-resources/BufferStore.ll
  LLVM :: CodeGen/SPIRV/opt-gepoperator-of-gvar.ll
  LLVM :: CodeGen/SPIRV/optimizations/add-check-overflow.ll
  LLVM :: CodeGen/SPIRV/optimizations/switch-condition-type.ll
  LLVM :: Frontend/HLSL/empty_cs_entry.ll
  LLVM-Unit :: Target/SPIRV/./SPIRVTests/40/56
  LLVM-Unit :: Target/SPIRV/./SPIRVTests/41/56
  LLVM-Unit :: Target/SPIRV/./SPIRVTests/42/56
  LLVM-Unit :: Target/SPIRV/./SPIRVTests/43/56
  LLVM-Unit :: Target/SPIRV/./SPIRVTests/49/56

@VyacheslavLevytskyy
Copy link
Contributor

@arsenm We currently do not select OpPhi during the instruction selection pass, instead we keep PHI until the module layout finalization stage (introduced as one of improvements in #119202 -- https://github.com/VyacheslavLevytskyy/llvm-project/blob/3e74d2c6983af986b70060ca44e6e1fbcb34a554/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp#L3354-L3369).

arsenm added 3 commits April 23, 2025 22:11
There should be no PHIs after selection, as OpPhi is used
instead. This hopefully avoids errors in #135277.
There should be no PHIs after selection, as OpPhi is used
instead. This hopefully avoids errors in #135277.
@arsenm arsenm force-pushed the users/arsenm/spirv/set-no-phis-after-select branch from 829c364 to 090b461 Compare April 23, 2025 20:14
@arsenm arsenm changed the title SPIRV: Set NoPHIs property after selection SPIRV: Set NoPHIs property after rewriting them Apr 23, 2025
@arsenm arsenm merged commit 66461db into main Apr 24, 2025
12 checks passed
@arsenm arsenm deleted the users/arsenm/spirv/set-no-phis-after-select branch April 24, 2025 09:14
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
There should be no PHIs after selection, as OpPhi is used
 instead. This hopefully avoids errors in llvm#135277.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
There should be no PHIs after selection, as OpPhi is used
 instead. This hopefully avoids errors in llvm#135277.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
There should be no PHIs after selection, as OpPhi is used
 instead. This hopefully avoids errors in llvm#135277.
Ankur-0429 pushed a commit to Ankur-0429/llvm-project that referenced this pull request May 9, 2025
There should be no PHIs after selection, as OpPhi is used
 instead. This hopefully avoids errors in llvm#135277.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants