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

SIMD vector equality returns true if ANY element is equal #4586

Open
Barinzaya opened this issue Dec 17, 2024 · 1 comment
Open

SIMD vector equality returns true if ANY element is equal #4586

Barinzaya opened this issue Dec 17, 2024 · 1 comment

Comments

@Barinzaya
Copy link
Contributor

Barinzaya commented Dec 17, 2024

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • Operating System & Odin Version: EndeavourOS/Arch Linux, Odin dev-2024-12 (and also on master)
	Odin:    dev-2024-12-nightly
	OS:      EndeavourOS, Linux 6.12.3-arch1-1
	CPU:     AMD Ryzen 9 9950X 16-Core Processor
	RAM:     61886 MiB
	Backend: LLVM 18.1.6

Expected Behavior

When comparing two SIMD vectors with ==, the result should be true if and only if every element is equal.

Current Behavior

The result is true if any element is equal, even if others are not.

Failure Information (for bugs)

Steps to Reproduce

Run the following sample code:

a := #simd[4]u32 { 1, 2, 3, 4 }
b := #simd[4]u32 { 1, 3, 4, 5 }
fmt.println(a == b)

This will print true, since the first element is equal. This is also the case for a b of 2,2,4,5, 2,3,3,5, and 2,3,4,4, which all have a single element that matches a.

@Creativty
Copy link

I just did a quick check on the resulting asm it gives a combo of (movaps which are load instructions, and pcmpeqd which is the compare instruction)
What I personally think is missing would be a section in the overview that mentions how SIMD semantics in odin match with the output assembly which might not be intuitive at first glance.
Reference: SIMD Reference Compare Packed Data for Equal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants