Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile/internal/ssa: incorrect type width when folding widening ops #67884

Open
pmur opened this issue Jun 7, 2024 · 2 comments
Open

cmd/compile/internal/ssa: incorrect type width when folding widening ops #67884

pmur opened this issue Jun 7, 2024 · 2 comments
Assignees
Labels
arch-ppc64x compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@pmur
Copy link
Contributor

pmur commented Jun 7, 2024

Go version

tip

Output of go env in your module/workspace:

GOARCH=ppc64le

What did you do?

Further exploration of lower rule improvements has uncovered problems when using a Value Type's size to determine whether to apply a rule.

E.g the rule in PPC64.rules:

(MOVWZreg y:(AND (MOVDconst [c]) _)) && uint64(c) <= 0xFFFFFFFF => y

And later in PPC64latelower.rules:

(AND <t> x:(MOVDconst [m]) n) && t.Size() == 4 && isPPC64WordRotateMask(m) => (RLWINM [encodePPC64RotateMask(0,m,32)] n)

If m is the value 0xF000000F or a similar wrapping mask on PPC64, the upper 32 bits of the value are not always 0. I think this only affects rules which use RLWINM and RLWNM. I believe they are the only GPR opcodes on PPC64 which have this behavior.

What did you see happen?

The latelower rule is triggered in cases where the result is expected to be wider than the assigned type

What did you expect to see?

The Type of the result in lower should reflected the widened type.

@pmur pmur added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jun 7, 2024
@pmur pmur self-assigned this Jun 7, 2024
@gabyhelp
Copy link

gabyhelp commented Jun 8, 2024

Similar Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@pmur
Copy link
Contributor Author

pmur commented Jun 10, 2024

I suspect this is not causing problems today. 32 bit constants are sign extended, and thus any wrapping mask would produce a negative int32 constant, which prevents the AND rule above from running for such constants.

@mknyszek mknyszek added this to the Backlog milestone Jun 12, 2024
@mknyszek mknyszek added the NeedsFix The path to resolution is known, but the work has not been done. label Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-ppc64x compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Projects
Development

No branches or pull requests

3 participants