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

Incorrect conversion of true bool to signed integer #680

Closed
AlexRTer opened this issue Mar 18, 2024 · 0 comments · Fixed by #744
Closed

Incorrect conversion of true bool to signed integer #680

AlexRTer opened this issue Mar 18, 2024 · 0 comments · Fixed by #744

Comments

@AlexRTer
Copy link
Collaborator

When casting a true bool to a signed integer of any length in a Daphne script it is cast to -1 instead of 1.

print(as.si8(true));     // -1
print(as.si32(true));    // -1
print(as.si64(true));    // -1

// print(as.ui64(true)); // 1

The IR immediately after parsing still shows:

%1 = "daphne.constant"() {value = true} : () -> i1
%2 = "daphne.cast"(%1) : (i1) -> si8

whereas after simplifications (parsing_simplified) these have been wrongfully folded to just

%2 = "daphne.constant"() {value = -1 : si8} : () -> si8
philipportner pushed a commit to AlexRTer/daphne that referenced this issue Jun 27, 2024
- conditional extension by signedness
- adds new test cases for ConstantFoldingTest
philipportner pushed a commit to AlexRTer/daphne that referenced this issue Jun 27, 2024
- conditional extension by signedness
- adds new test cases for ConstantFoldingTest
philipportner pushed a commit that referenced this issue Jun 27, 2024
- conditional extension by signedness
- adds new test cases for ConstantFoldingTest
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 a pull request may close this issue.

1 participant