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

Use XOR to translate more == and != expressions #34168

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ranma42
Copy link
Contributor

@ranma42 ranma42 commented Jul 5, 2024

When the parent expression is not a predicate, translate x != y to:

CAST(x ^ y AS BIT)

instead of

CASE
    WHEN x <> y THEN CAST(1 AS bit)
    ELSE CAST(0 AS bit)
END

Similarly, translate x == y to:

CAST(x ^ y AS BIT) ^ CAST(1 AS bit)

instead of

CASE
    WHEN x == y THEN CAST(1 AS bit)
    ELSE CAST(0 AS bit)
END

Contributes to #34001.

When the parent expression is not a predicate, translate `x != y` to:
```sql
CAST(x ^ y AS BIT)
```

instead of

```sql
CASE
    WHEN x <> y THEN CAST(1 AS bit)
    ELSE CAST(0 AS bit)
END
```

Similarly, translate `x == y` to:

```sql
CAST(x ^ y AS BIT) ^ CAST(1 AS bit)
```

instead of

```sql
CASE
    WHEN x == y THEN CAST(1 AS bit)
    ELSE CAST(0 AS bit)
END
```

Contributes to dotnet#34001.
@ranma42
Copy link
Contributor Author

ranma42 commented Jul 5, 2024

This extends #34124 to all integer types.

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

Successfully merging this pull request may close these issues.

None yet

1 participant