[PATCH] D159376: [SPIRV] Fix OpConstant float lowering and writing
Natalie Chouinard via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 1 13:05:20 PDT 2023
sudonatalie created this revision.
Herald added subscribers: pmatos, ThomasRaoux, hiraditya.
Herald added a project: All.
sudonatalie updated this revision to Diff 555486.
sudonatalie added a comment.
sudonatalie published this revision for review.
sudonatalie added a reviewer: mpaszkowski.
Herald added a reviewer: zuban32.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
math.h -> APFloat
The previous logic where float constant were stored as integers in Imm
operands posed a problem when printing the textual SPIR-V instructions
because the operand bits were interpreted as an integer which was
numerically cast to a double rather than bitwise cast. This resulted in
the wrong numeric value being output to the SPIR-V module.
AtomicBuiltinsFloat.ll had an example of this incorrect casting.
This patch fixes this issue by storing literal float operands in a
DFPImm instead, and bitwise casting when lowering and printing. The
values are now printed as formatted decimal floating points, with
special case exceptions to print infinity and NaN as hexfloats.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D159376
Files:
llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVInstPrinter.cpp
llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
llvm/lib/Target/SPIRV/SPIRVMCInstLower.cpp
llvm/test/CodeGen/SPIRV/AtomicBuiltinsFloat.ll
llvm/test/CodeGen/SPIRV/literals.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159376.555486.patch
Type: text/x-patch
Size: 5157 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230901/d1922f58/attachment.bin>
More information about the llvm-commits
mailing list