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
[RISCV] Missed oppurtunity in memory overlap check idiom #56518
Comments
@llvm/issue-subscribers-backend-risc-v |
The xori with 1 come from isel because we don't have sgeu. So we invert an sltu with xori. There's nothing downstream that can apply demorgan to it. |
I am investigating this issue and have already created patterns for @reduced @test and @test2. For @reduced and @test2
can be changed directly to
but in case @test condition was changed with De Morgan's Law. ((a < c) or (b < c)) changes to !((a >= c) and (b >= c)) and can therefore be changed to min(a, b) >= c. Since we do not have sgeu, the logic above can be changed to (min(a, b) < c) xor 1. Additionally, there are lots of patterns to apply this kind of optimization.
Plus, |
Patch with possible cases on review: |
Done. |
The LoopVectorizer will emit a memory overlap check of the form:
./llc -march=riscv64 -mattr=+v,+m,+zba,+zbb < vector_overlap.ll -O3
currently results in:Unless I'm missing something, we should be able to rewrite this as:
This does require zbb, but the command line above explicitly includes that.
Separately, there appears to be something weird going on block placement and branch inversion. Compare the following inputs and outputs:
Produces:
I believe the second is a separate issue. I'm filing them together only because I'm not sure if this is related to the first one somehow. We can split it into its own bug if it turns out not.
The text was updated successfully, but these errors were encountered: