This patch implements C-style explicit type conversions in CXX for matrix types. It is part of fixing https://bugs.llvm.org/show_bug.cgi?id=47141
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Time | Test | |
---|---|---|
2,630 ms | x64 debian > libarcher.races::lock-unrelated.c |
Event Timeline
Thanks for the patch!
It looks like there might be a few cases where the wrong conversion is used at the moment.
clang/test/CodeGenCXX/matrix-casts.cpp | ||
---|---|---|
27 | Shouldn't this use zext for the conversion? Possibly that's an issue with the existing conversion code for matrixes? | |
67 | Shouldn't this use sitofp for the conversion? Possibly that's an issue with the existing conversion code for matrixes? | |
clang/test/SemaCXX/matrix-casts.cpp | ||
25–30 | can you also add a test with an assignment without cast? This should be an error. |
clang/test/CodeGenCXX/matrix-casts.cpp | ||
---|---|---|
27 | Would definitely debug it but would like to quickly clarify this. This is the code that's being executed. For int->int conversion, we are just checking the whether input is signed and regardless of whether output type is signed, we do CreateIntCast. We probably need to check OutputSigned too, right? |
clang/test/CodeGenCXX/matrix-casts.cpp | ||
---|---|---|
27 | Nevermind, the scalar version I checked used zext due to some AArch64 specific optimization! So sext should be fine here. But that still leaves the int->float case. https://clang.godbolt.org/z/a5Tjed7sP |
Updating D101696: [Matrix] Implement C-style explicit type conversions in CXX for matrix types
- Remove bitcast when types are of the same size.
- Make int conversion depend on whether both input and output are signed.
- Add a test case of assigning to an incorrect type.
Thanks for your review @fhahn . I have made some changes in CGExprScalar.cpp to address your comments on IR. I have also added a statement to test assignment to incorrect type.
clang/test/CodeGenCXX/matrix-casts.cpp | ||
---|---|---|
27 | Whoops, did not see your updated comment. Reverting that change. |
Thanks for the update! Technically the fix in clang/lib/CodeGen/CGExprScalar.cpp is unrelated to C++ support. It would be great if you could put up a separate patch, so we can land this independently.
The whole patch basically LGTM. It would be great if you could add a test casting from unsigned to float/double (looks like no test generates uitofp) and a test for casting between signed & unsigned integers of the same size (unless there are already tests for that I missed)
clang/lib/CodeGen/CGExprScalar.cpp | ||
---|---|---|
1209 | Could you s | |
clang/test/CodeGenCXX/matrix-casts.cpp | ||
4 | nit: drop the newline here and before using matrix_5_5... |
Sure thing. I have created a new patch here https://reviews.llvm.org/D101754. Once that's merged, I will rebase this one with the new main.
Rebase with main and add new tests for uitofp, unsigned int to int, and int to unsigned int
LGTM, thanks!
I can land this on your behalf tomorrow.
After that I think you could apply for commit access https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access :)
Perhaps for bonus points, update the Clang documentation in https://clang.llvm.org/docs/LanguageExtensions.html#matrix-types with some examples?
Can you please point me to how to submit patches to the documentation? I could only find links like https://clang.llvm.org/hacking.html which talk about code patches. Many thanks.
It works exactly the same as other patches. I think the file you're interested in is llvm-project/clang/docs/LanguageExtensions.rst.
Could you s