Skip to content

Use LDE to load single precision floating point values - #6834

Merged
0xdaryl merged 1 commit into
eclipse-omr:masterfrom
r30shah:ReplaceLEwithLDE
Dec 7, 2022
Merged

0xdaryl merged 1 commit into
eclipse-omr:masterfrom
r30shah:ReplaceLEwithLDE

Conversation

@r30shah

@r30shah r30shah commented Dec 1, 2022

Copy link
Copy Markdown
Contributor

LE instruction on IBM Z loads single precision floating values into the FPR register. In certain scenarios this operation may perform poorly espcecially in case of Write after Read or Write after Write scenario where hardware may not be able to break the dependency chain. In such scenarios, using LDE instruction to load from memory would help. This commit replaces the use of LE instruction with LDE.

Signed-off-by: Rahil Shah rahil@ca.ibm.com

@r30shah
r30shah requested a review from fjeremic as a code owner December 1, 2022 21:16
@r30shah

r30shah commented Dec 1, 2022

Copy link
Copy Markdown
Contributor Author

@joransiu Can I get a review on this one ?

@joransiu joransiu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @r30shah, can you double check with a test the long disp unresolved patching path is safe? Given RXE is not a common format, and it only has 12-bits of displacement, I worry we might missed something, which would be a hard bug to figure out in the field. From my review of the OpenJ9 PicBuilder code and its OOL long disp handling, it should all work, as we only patch up to 4K.

@r30shah

r30shah commented Dec 2, 2022 •

Copy link
Copy Markdown
Contributor Author

@joransiu Looking at the PIC builder code and the unresolved snippet we emit, it works well with RXE type instruction as well as you said. I have confirmed it with unit test. Though your comment Given RXE is not a common format inspired me to verify out the resolved long displacement with RXE instruction as well (While making this change, I did look at the memory reference's binary encoding code and did see we were treating long displacement for the RXE instruction as well [1]). It does handle the long displacement but in certain case introduces the bug. Here is the instructions we generate at instruction selection.

[     0x3ff67126270]	                       LDE     FPR_0040, Shadow[<array-shadow>] 8208(&GPR_0034),0

When we generate binary, we see that the displacement is very large and we can not use the displacement field in the instruction, so in [2], it frees up a scratch register and uses LGHI to store the displacement. Here is the instruction at binary encoding.

     0x3ff6c97f14a 0000004e STG     GPR2,#417 32(GPR5)
     0x3ff6c97f150 00000054 LGHI    GPR2,0x2010
     0x3ff6c97f14a 0000004e LDE     FPR0, Shadow[<array-shadow>] 0(GPR2,GPR1),0

Please notice, we free up GPR2 by spilling it onto the stack but do no preserve it back. Such touch up for the long displacement is handled in [3] but for RXE type instruction we actually never call it 😞

I have updated the instruction api for RXE type instruction to call this routine to restore spilled register in f76bd35

Relaunching tests, Marking it WIP while they finish

[1]. https://github.com/eclipse/omr/blob/310f0efc871923145d85dd1f450b6a08dd11ef35/compiler/z/codegen/OMRMemoryReference.cpp#L2919
[2]. https://github.com/eclipse/omr/blob/310f0efc871923145d85dd1f450b6a08dd11ef35/compiler/z/codegen/OMRMemoryReference.cpp#L3019-L3028
[3]. https://github.com/eclipse/omr/blob/310f0efc871923145d85dd1f450b6a08dd11ef35/compiler/z/codegen/OMRMemoryReference.cpp#L3203

LE instruction on IBM Z loads single precision floating values into the
FPR register. In certain scenarios this operation may perform poorly
espcecially in case of Write after Read or Write after Write scenario
where hardware may not be able to break the dependency chain. In such
scenarios, using LDE instruction to load from memory would help. This
commit replaces the use of LE instruction with LDE.
Also while testing the changes we found out that for RXE type
instructions we were not handling long displcement correctly and
introducing a bug where it would store the scratch register to stack but
does not restore it back. It is fixed in this commit.

Signed-off-by: Rahil Shah <rahil@ca.ibm.com>
@r30shah

r30shah commented Dec 5, 2022

Copy link
Copy Markdown
Contributor Author

@joransiu change in compiler/z/codegen/S390Instruction.cpp takes care of generating necessary touch up for the RXE type instruction if the long displacement is encountered.

I have tested out this changes with Java 8 Personal build (build_info.php?build_id=41428) on z/OS and Linux on Z as well as with JDK11 (LoZ) view/OpenJ9 - Personal/job/Pipeline-Build-Test-Personal/15043/

This one is ready for review, I am launching OMR tests on this

@r30shah

r30shah commented Dec 5, 2022

Copy link
Copy Markdown
Contributor Author

Jenkins build zos,zlinux

@joransiu joransiu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nice catch on the long disp fixup!

@r30shah

r30shah commented Dec 5, 2022

Copy link
Copy Markdown
Contributor Author

@0xdaryl Can I request you to merge this change?

@0xdaryl 0xdaryl self-assigned this Dec 7, 2022
@0xdaryl
0xdaryl merged commit fb5a91e into eclipse-omr:master Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants