Repository navigation
Conversation
InstCombine narrows a switch's condition to the bits it can take, which leaves a `switch i1`
when Julia 1.10 union-splits on a value with two possible types. The SPIR-V back-end translates
that to an OpSwitch on a boolean, which is invalid ("Type Id is not a scalar numeric type"), so
zero-extend such conditions to `i32` right before translation, after the InstCombine run in
`prepare_execution!`. Hit by AcceleratedKernels.jl's scans of bits-union arrays on OpenCL.
Member
Author
|
Going to fix this in LLVM instead. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
InstCombine narrows a switch's condition to the bits it can take. When Julia 1.10 union-splits on a value with two possible types, that can leave a
switch i1. LLVM's SPIR-V back-end translates it to anOpSwitchon a boolean, which is invalid SPIR-V:A minimal module shows the same with LLVM 23's
llc -mtriple=spirv64:This PR zero-extends such conditions to
i32right before translation, keeping each switch's successors so that phis are unaffected. Likewiden_bfloat16!, it runs inmcgenbecause the InstCombine inprepare_execution!would narrow the condition again; I first put it infinish_ir!, and that didn't help.This came up in JuliaGPU/AcceleratedKernels.jl#199, in a scan of a bits-union array on OpenCL with Julia 1.10 and
--check-bounds=yes. With this branch, that test suite passes.