[all-commits] [llvm/llvm-project] 37a3c0: [mlir][ArithToSPIRV] Fix uitofp/sitofp for emulate...
Quinn Dawkins via All-commits
all-commits at lists.llvm.org
Thu Mar 12 08:55:33 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 37a3c013f2506886a00b26831146eedab3fb4cd9
https://github.com/llvm/llvm-project/commit/37a3c013f2506886a00b26831146eedab3fb4cd9
Author: Quinn Dawkins <quinn.dawkins at gmail.com>
Date: 2026-03-12 (Thu, 12 Mar 2026)
Changed paths:
M mlir/lib/Conversion/ArithToSPIRV/ArithToSPIRV.cpp
M mlir/test/Conversion/ArithToSPIRV/arith-to-spirv.mlir
Log Message:
-----------
[mlir][ArithToSPIRV] Fix uitofp/sitofp for emulated narrow integer types (#186136)
When a SPIR-V target lacks Int8/Int16 capabilities, narrow integers are
emulated as i32. The upper bits of the i32 container may contain garbage
(e.g., sign-extended bits from packed byte extraction).
Previously, arith.uitofp and arith.sitofp on these emulated types would
use the generic TypeCastingOpPattern, which either forwards the operand
unchanged (when src/dst types match after conversion) or creates a plain
spirv.ConvertUToF/ConvertSToF without cleaning the upper bits. This
produces incorrect results.
This was exposed by arith canonicalization patterns (UIToFPOfExtUI,
SIToFPOfExtSI) that fold uitofp(extui(x)) -> uitofp(x) and
sitofp(extsi(x)) -> sitofp(x), eliminating the ext operations which were
incidentally cleaning the upper bits.
Replace TypeCastingOpPattern for UIToFP/SIToFP with IntToFPPattern, a
single template parameterized on signedness that handles both widening
and non-widening cases:
- Unsigned: masks with BitwiseAnd before ConvertUToF.
- Signed: sign-extends via ShiftLeftLogical + ShiftRightArithmetic
before ConvertSToF.
---------
Co-authored-by: Claude Opus 4.6 <noreply at anthropic.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list