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

Cast of prim to small types gives no feedback #69

Closed
eponier opened this issue Oct 28, 2021 · 2 comments
Closed

Cast of prim to small types gives no feedback #69

eponier opened this issue Oct 28, 2021 · 2 comments

Comments

@eponier
Copy link
Contributor

eponier commented Oct 28, 2021

Consider this example

export fn f (reg u128 x y) -> reg u128 {
   reg u128 z;
   z = (32u)#VPAND(x, y);
   return z;
}

This example compiles fine. The cast (32u) is silently ignored. I think this is done on purpose, but really confusing for the user that has no feedback on what happens. An error would be more user-friendly. Or a warning explaining that this is ignored.

@eponier
Copy link
Contributor Author

eponier commented Oct 28, 2021

The cast is "ignored" since VPAND is by default VPAND_128 and 32 < 128. Actually, the cast is there, but not taken into account for typing.

@eponier
Copy link
Contributor Author

eponier commented Oct 29, 2021

Actually after discussing a bit with @bgregoir, these are not really casts but instead instruction modifiers. Maybe we should think of another syntax then?

Here is another counter-intuitive example. The first one compiles fine, since (32u) is ignored like in the first example above. And the second fails with the message: "typing error: can not implicitly cast u32 into u64". While without (32u) they are both compiled to the same assembly.

export fn f (reg u64 x y) -> reg u64 {
   reg u64 z;
   reg u64 x1 y1;
   x1 = x;
   y1 = y;
   z = (32u)#AND(x1, y1);
   return z;
}
export fn f (reg u64 x y) -> reg u64 {
   reg u64 z;
   reg u64 x1 y1;
   x1 = x;
   y1 = y;
   z = (32u)x1 & y1;
   return z;
}

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

1 participant