AFAICT, the trunc is not needed for correctness/performance and just
blocks what should be handlable cases.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
| llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | ||
|---|---|---|
| 739 | Unless I'm missing something, we're missing an assignment to the V variable in this branch now? Also, do we still need the NeedAnd? We should really just be using decomposeBitTestICmp() and a pow2 check I think, but this code is doing some very weird things I don't fully get. | |
| llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | ||
|---|---|---|
| 739 |
Good catch not sure how that didn't get caught in the tests.
Yes. x >= 0 == x & SignBit == 0 but we don't have the actual x & SignBit expression.
I think that works. Will make it a follow up patch to this. | |
| llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | ||
|---|---|---|
| 739 |
Done.
See: D148744 | |
| llvm/test/Transforms/InstCombine/select-with-bitwise-ops.ll | ||
|---|---|---|
| 772 | Can you add a multi-use variant of this test? I think the reason why this code is checking for the trunc is that it replaces a one-use trunc with an and, which preserves the number of uses. If we drop the check, we'll have to take NeedsAnd into account when counting uses. | |
| llvm/test/Transforms/InstCombine/select-with-bitwise-ops.ll | ||
|---|---|---|
| 772 | Good point. Added NeedAnd to muiltiuse check. | |
Unless I'm missing something, we're missing an assignment to the V variable in this branch now? Also, do we still need the NeedAnd?
We should really just be using decomposeBitTestICmp() and a pow2 check I think, but this code is doing some very weird things I don't fully get.