[PATCH] D140988: [SystemZ] Implement lowering of GET_ROUNDING

Ulrich Weigand via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 11 01:21:20 PST 2023


uweigand added a comment.

With the changed pointed out by @nikic this looks good to me.

Optionally, there seems to be one more minor optimization opportunity. Looking at the generated code:

  efpc %r0
  nilf %r0, 3
  lr %r1, %r0
  xilf %r1, 2
  rxsbg %r0, %r1, 33, 63, 63

I see that it should be possible to save one more instruction (and one register) by doing instead:

  efpc %r0
  nilf %r0, 3
  rxsbg %r0, %r0, 33, 63, 63
  xilf %r0, 1

I.e. re-associating the XORs to compute

  CWD1 = efpc() & 3
  CWD2 = (CWD1 ^ (CWD1 >> 1)) ^ 1



> But , AFAIU, the LLGFR is needed after RXSBG anyway.

It's needed in your test case because the result is returned from the function, and function return values are implicitly extended in our ABI.  If it were not directly returned, but used in some other way, the extension might not always be necessary.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140988/new/

https://reviews.llvm.org/D140988



More information about the llvm-commits mailing list