Skip to content

Fix codegen branch for cond ? ~0 : 0#14945

Merged
RazvanN7 merged 1 commit intodlang:stablefrom
dkorpel:ternary-codegen
Mar 8, 2023
Merged

Fix codegen branch for cond ? ~0 : 0#14945
RazvanN7 merged 1 commit intodlang:stablefrom
dkorpel:ternary-codegen

Conversation

@dkorpel
Copy link
Contributor

@dkorpel dkorpel commented Mar 2, 2023

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @dkorpel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "stable + dmd#14945"

Copy link
Contributor

@thewilsonator thewilsonator left a comment

Choose a reason for hiding this comment

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

Testcase?

@dkorpel dkorpel marked this pull request as ready for review March 2, 2023 14:07
@dkorpel
Copy link
Contributor Author

dkorpel commented Mar 2, 2023

The testcase was added in the previous PR.

cdb.gen2(0xF6 + (opcode & 1),grex | modregrmx(3,2,reg)); // NOT reg
if (I64 && sz2 == REGSIZE)
if (I64 && sz2 == 1 && reg >= 4)
code_orrex(cdb.last(), REX_W);
Copy link
Member

Choose a reason for hiding this comment

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

No. Leave 2417 and 2418 intact. Insert the following after 2418:

        if (I64 && sz2 == 1 && reg >= 4)
            code_orrex(cdb.last(), REX);

Copy link
Member

@WalterBright WalterBright Mar 3, 2023

Choose a reason for hiding this comment

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

This pattern is used in the surrounding code. Whenever you see an odd 'H' register in the codegen output, this is the fix.

Copy link
Contributor Author

@dkorpel dkorpel Mar 3, 2023

Choose a reason for hiding this comment

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

Thanks. It's a bit concerning the test suite isn't red because of this.

{
cdb.gen2(0xF6 + (opcode & 1),grex | modregrmx(3,2,reg)); // NOT reg
if (I64 && sz2 == REGSIZE)
code_orrex(cdb.last(), REGSIZE);
Copy link
Member

Choose a reason for hiding this comment

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

code_orrex(cdb.last(), REX_W);

cdb.gen2(0xF6 + (opcode & 1),grex | modregrmx(3,2,reg)); // NOT reg
if (I64 && sz2 == REGSIZE)
code_orrex(cdb.last(), REGSIZE);
if (I64 && sz2 == 1 && reg >= 4)
Copy link
Member

Choose a reason for hiding this comment

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

Next line is:
code_orrex(cdb.last(), REX);

@WalterBright
Copy link
Member

@dkorpel what is happening with this?

@dkorpel
Copy link
Contributor Author

dkorpel commented Mar 7, 2023

Ironically, it was all green when it had the wrong code twice, and now when I finally got your suggestion right, the test suite spuriously fails.

@dkorpel
Copy link
Contributor Author

dkorpel commented Mar 8, 2023

I've force pushed multiple times now, but some tests are still stuck

@RazvanN7 RazvanN7 merged commit 9e3e295 into dlang:stable Mar 8, 2023
@dkorpel dkorpel deleted the ternary-codegen branch March 8, 2023 14:52
@ibuclaw ibuclaw mentioned this pull request Mar 15, 2023
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.

5 participants