This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Fix FLT_ROUNDS_ on little endian
ClosedPublic

Authored by qiucf on Nov 19 2020, 11:45 PM.

Details

Summary

Opcode FLT_ROUNDS_ is lowered as:

  1. Move FPSCR content to an FP register
  2. Move lower 32 bits into a GPR
  3. Adjust its value, and return

For subtargets without direct move support, it will store and then load. The load address needs adjustment (+4) only on big-endian targets. This patch fixes it on little-endian and will try direct move instruction first.

Diff Detail

Event Timeline

qiucf created this revision.Nov 19 2020, 11:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 19 2020, 11:45 PM
qiucf requested review of this revision.Nov 19 2020, 11:45 PM
steven.zhang added inline comments.Nov 25 2020, 9:53 PM
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
8899

Can we use some generic node to express this semantic ? So that , we will handle it automatically. i.e.
x = MFFS
y = bitcast f64 to i64
z = trunc y to i32

qiucf updated this revision to Diff 307760.Nov 25 2020, 10:38 PM
qiucf marked an inline comment as done.

Use bitcast-truncate

llvm/lib/Target/PowerPC/PPCISelLowering.cpp
8899

Yes. But the original code needs to be kept for ppc32 (i64 is illegal on that so crash will happen for the bitcast).

steven.zhang added inline comments.Dec 1 2020, 9:16 PM
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
8942

Is it better to check the type legal for i64 ? We cannot do this for PPC32 is because that, the i64 is not legal and we are not allowed to produce the illegal type during legalizeOp.

8946

Add an assertion here:
assert(hasBigEndianPartOrdering(...))

qiucf updated this revision to Diff 308888.Dec 2 2020, 12:02 AM
qiucf marked 2 inline comments as done.

Address comments

steven.zhang accepted this revision.Dec 2 2020, 12:26 AM

LGTM now. Thank you for doing this.

This revision is now accepted and ready to land.Dec 2 2020, 12:26 AM
This revision was automatically updated to reflect the committed changes.