You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PR #24121 set includeApplyRescale = true in buildTOSAInputConversionPassPipeline, unconditionally lowering tosa.apply_scale to 64-bit arith ops during input conversion.
This breaks existing 32-bit backend lowerings:
RISC-V Zve32* (LLVMCPU, ConvertToLLVM.cpp): breaks 32-bit vmulh vectorization, regressing to scalarized 64-bit multiplies and significant .text blowup on ELEN = 32 targets.
SPIR-V (SPIRV/Passes.cpp): breaks use32BitApplyRescale = true (spirv.SMulExtended), forcing 64-bit integer arithmetic / emulation on targets without Int64.
At the same time, VerifyCompilerTOSAInputLegality, Flow/VerifyInputLegality, LLVMCPU, SPIR-V, and VMVX still keep tosa.apply_scale legal/lowered, while LLVMGPU still lacks lowering (e.g. mul_shift.mlir is excluded) and upstream MLIR just removed VectorUnrollOpInterface from tosa.apply_scale in llvm/llvm-project#238010 (#25295).
What is the intended upstream direction?
Restore backend-owned lowering (includeApplyRescale = false) and add tosa.apply_scale lowering to LLVMGPU, or
Keep includeApplyRescale = true by default (with an option to preserve it, or retiring the backend tosa.apply_scale paths)?
(Side note: with llvm.intr.smulh now in MLIR/LLVM, LLVMCPU's ExpandMulSIExtended can also lower directly to llvm.mul + llvm.intr.smulh without ever materializing i64 vectors.)
Thank you for submitting an issue to IREE! It looks like it's your first one.
The volume of issues is huge, and triage times may vary. If you need quicker assistance on the issue, consider posting it on IREE Discord and providing short context there.
Feel free to identify the most frequent contributors to the corresponding part of the codebase via Git history/CODEOWNERS and (gently!) tag them below.
IREE is a Linux Foundation project. All participants are expected to follow the LF Projects Code of Conduct.
Please note that all contributions to IREE, including GitHub issues, must follow our IREE AI Tool Use Policy. This means:
Issue reporters must fully understand the primary issue and the impact of the problem.
For bug reports, specifics of the use-case, workflow and/or crash scenario usually suffice.
For improvement suggestions, this usually implies deeper understanding of suboptimal code, IR design choices, assumed performance tradeoffs, etc.
Contributors must write the summary of the issue themselves, so that the exact impact and scenario is clear to other participants.
Issue authors are expected to review and understand all LLM/AI-assisted segments of the report, if any. E.g.: CLI commands and IR reproducers, model/framework details, lowering pipeline details, assumptions about problematic behaviors of IREE components.
Substantial use of LLM/generative AI tools must be disclaimed in the header or footer of the issue description.
Before the issue can be triaged, we kindly ask you to reply to this message and confirm that you understand and accept the proposed policy. As required, please adjust your initial issue description.
If you have any questions, feel free to leave a comment here, or ask away on IREE Discord.
Thanks for reporting this! I looked into the regression and a bit of history behind #24121. While I'm not entirely sure what the original vectorization failure was, it might have been related to tosa.apply_scale not accepting rank-0 vectors. If that's the case, this has since been fixed in llvm/llvm-project#199924.
I'd lean towards option 1 and leave the lowering to the individual backends, since we already have target-specific lowering for LLVMCPU and SPIR-V. We would need to add the missing lowering in LLVMGPU.
For SPIR-V, as you mentioned, VectorUnrollOpInterface was removed from tosa.apply_scale. Since the current pipeline lowers tosa.apply_scale after vector unrolling, this could be an issue for vectors that need to be unrolled. Moving the 32-bit lowering before the vector unrolling wouldn't help either, as it introduces arith.mulsi_extended, which produces multiple results and isn't supported by the generic elementwise unrolling patterns.
I think there are two ways we could address this:
Restore the interface in upstream llvm with proper tests
Attach the unroll interface as an external model in iree since we already follow a similar pattern for other interfaces (e.g. in Codegen/Interfaces/VectorizableOpInterface.cpp).
@Manewing do you recall which cases originally motivated #24121? It would be good to know if there are any other issues that we need to account for.
Activity
github-actions commentedon Nov 26, 2026
Hello @fshaked 👋
Thank you for submitting an issue to IREE! It looks like it's your first one.
The volume of issues is huge, and triage times may vary. If you need quicker assistance on the issue, consider posting it on IREE Discord and providing short context there.
Feel free to identify the most frequent contributors to the corresponding part of the codebase via Git history/CODEOWNERS and (gently!) tag them below.
Action required: acknowledge IREE project policies
IREE is a Linux Foundation project. All participants are expected to follow the LF Projects Code of Conduct.
Please note that all contributions to IREE, including GitHub issues, must follow our IREE AI Tool Use Policy. This means:
For bug reports, specifics of the use-case, workflow and/or crash scenario usually suffice.
For improvement suggestions, this usually implies deeper understanding of suboptimal code, IR design choices, assumed performance tradeoffs, etc.
Before the issue can be triaged, we kindly ask you to reply to this message and confirm that you understand and accept the proposed policy. As required, please adjust your initial issue description.
If you have any questions, feel free to leave a comment here, or ask away on IREE Discord.
Thank you,
The IREE Community
phemashekar commentedon Nov 26, 2026
Thanks for reporting this! I looked into the regression and a bit of history behind #24121. While I'm not entirely sure what the original vectorization failure was, it might have been related to
tosa.apply_scalenot accepting rank-0 vectors. If that's the case, this has since been fixed in llvm/llvm-project#199924.I'd lean towards option 1 and leave the lowering to the individual backends, since we already have target-specific lowering for LLVMCPU and SPIR-V. We would need to add the missing lowering in LLVMGPU.
For SPIR-V, as you mentioned,
VectorUnrollOpInterfacewas removed fromtosa.apply_scale. Since the current pipeline lowerstosa.apply_scaleafter vector unrolling, this could be an issue for vectors that need to be unrolled. Moving the 32-bit lowering before the vector unrolling wouldn't help either, as it introducesarith.mulsi_extended, which produces multiple results and isn't supported by the generic elementwise unrolling patterns.I think there are two ways we could address this:
Codegen/Interfaces/VectorizableOpInterface.cpp).@Manewing do you recall which cases originally motivated #24121? It would be good to know if there are any other issues that we need to account for.