Open soooch opened 2 weeks ago
@llvm/issue-subscribers-clang-codegen
Author: Suchir Kavi (soooch)
Not sure how to change the label, but it should probably be missed-optimization
Hi!
This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:
test/
create fine-grained testing targets, so you can e.g. use make check-clang-ast
to only run Clang's AST tests.git clang-format HEAD~1
to format your changes.If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.
@llvm/issue-subscribers-good-first-issue
Author: Suchir Kavi (soooch)
I'm interested in trying this out if no one else is already planning on it.
Would appreciate an example of a good, similar PR if anyone has one off hand.
found where the "select c 1 0 -> zext c" transform is being done for ints: https://github.com/llvm/llvm-project/blob/3bc38fb27a12f785d8e78b8d00cbd277464ace92/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp#L3683
seems it's just inlined in the top level function. assume it's probably best to break the logic out before adding to it?
Not sure if all target can benefit from it (e.g. no native FP support). If you just want to change for X86, I think you may do it in combineSelectOfTwoConstants
.
https://clang.godbolt.org/z/nP35reYMz
I'd definitely recommend this is done in the DAG and not the middle end. Best to start with x86 and we can consider generalizing it in the future.
@llvm/issue-subscribers-backend-x86
Author: Suchir Kavi (soooch)
rust src: https://godbolt.org/z/3jjdq1ex1 c src: https://godbolt.org/z/q847cx4G3
Given the following Rust source:
We end up with the following before x86 inst selection:
And eventually the following x86 codegen:
Ideally we'd probably like to see this converted to:
On x86, this would give us:
On the integer side,
InstCombinePass
is able to transformselect i1 %x, i32 1, i32 0
tozext i1 %x to i32
. That seems like a somewhat similar operation, but I'm not very familiar with LLVM.