This is an archive of the discontinued LLVM Phabricator instance.

Fix printing of f16 machine operands
ClosedPublic

Authored by rampitec on Feb 3 2016, 4:09 PM.

Details

Reviewers
arsenm
hfinkel
Summary

Only single and double FP immediates are correctly printed by MachineInstr::print() during debug output. Half float type goes to APFloat::convertToDouble() and hits assertion it is not a double semantics. This diff prints half machine operands correctly.

Diff Detail

Event Timeline

rampitec updated this revision to Diff 46847.Feb 3 2016, 4:09 PM
rampitec retitled this revision from to Fix printing of f16 machine operands.
rampitec updated this object.
rampitec added a reviewer: arsenm.
rampitec set the repository for this revision to rL LLVM.
rampitec added a subscriber: llvm-commits.
hfinkel added a subscriber: hfinkel.Feb 3 2016, 4:22 PM

Please include a test case (you'll need to put '; REQUIRES: asserts' in it if you're checking debug output. Maybe, however, you can get the same problem if you use MIR, in which case that would be better.

MachineInstr.cpp
379 ↗(On Diff #46847)

unused -> Unused

Please include a test case (you'll need to put '; REQUIRES: asserts' in it if you're checking debug output. Maybe, however, you can get the same problem if you use MIR, in which case that would be better.

The testcase is simple:

; RUN: llc -march=hsail -print-after=dead-mi-elimination < %s 2>&1 | FileCheck %s
; CHECK: half 4.000000e+00
define half @half_const(half %in) {
entry:

%add = fadd half %in, 0xH4400
ret half %add

}

Though I found no backend in the trunk where a half immediate survives instruction selection and present as machine operand, thus I do not see what to put into -march for testing.

rampitec updated this revision to Diff 46851.Feb 3 2016, 4:28 PM
rampitec removed rL LLVM as the repository for this revision.

Changed unused => Unused.

hfinkel accepted this revision.Feb 3 2016, 4:28 PM
hfinkel added a reviewer: hfinkel.

Please include a test case (you'll need to put '; REQUIRES: asserts' in it if you're checking debug output. Maybe, however, you can get the same problem if you use MIR, in which case that would be better.

The testcase is simple:

; RUN: llc -march=hsail -print-after=dead-mi-elimination < %s 2>&1 | FileCheck %s
; CHECK: half 4.000000e+00
define half @half_const(half %in) {
entry:

%add = fadd half %in, 0xH4400
ret half %add

}

Though I found no backend in the trunk where a half immediate survives instruction selection and present as machine operand, thus I do not see what to put into -march for testing.

Ah, okay. In that case, with unused capatilized to match project coding conventions, this LGTM. Just mention in the commit message that we can't (yet) hit this with any in-tree target.

This revision is now accepted and ready to land.Feb 3 2016, 4:28 PM
majnemer added inline comments.
lib/CodeGen/MachineInstr.cpp
375–384

Please consistently use braces.

rampitec updated this revision to Diff 46853.Feb 3 2016, 5:08 PM
rampitec edited edge metadata.

Changed braces use.

arsenm closed this revision.Feb 4 2016, 4:54 PM
arsenm edited edge metadata.

r259857