This is an archive of the discontinued LLVM Phabricator instance.

[mips] Fix loading "double" immediate into a GPR and FPR
ClosedPublic

Authored by atanasyan on Oct 10 2019, 3:26 AM.

Details

Summary

If a "double" (64-bit) value has zero low 32-bits, it's possible to load such value into a GP/FP registers as an instruction immediate. But now assembler loads only high 32-bits of the value.

For example, if a target register is GPR the li.d $4, 1.0 instruction converts into the lui $4, 16368 one. As a result, we get 0x3FF00000 in the register. While a correct representation of the 1.0 value is 0x3FF0000000000000. The patch fixes that.

Diff Detail

Event Timeline

atanasyan created this revision.Oct 10 2019, 3:26 AM
mstojanovic accepted this revision.Oct 10 2019, 9:46 AM

LGTM, just have some clarifying questions.

llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
3481

An alternative to this condition could be isGP64bit(). Do you think there's a case where this wouldn't work and what do you prefer?

3482

Is there a reason why the IsAddress argument is set to true in the loadImmediate() call?

This revision is now accepted and ready to land.Oct 10 2019, 9:46 AM
atanasyan marked 2 inline comments as done.Oct 11 2019, 4:50 AM
atanasyan added inline comments.
llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
3481

I'm going to fix that and other similar code by a separate patch.

3482

Good point, thanks. I missed that and just use the same value for this argument as in the original code. I think in both loadImmediate calls IsAddress should be false. I will fix that before commit.

This revision was automatically updated to reflect the committed changes.