feat(RISCVCombines): add combines to speed-up ChaCha20 - #1344
tobias-rothmann wants to merge 9 commits into
Conversation
c7f46ad to
897c18b
Compare
897c18b to
1eb01e2
Compare
f2ee4fc to
9c361d5
Compare
3155a69 to
55e829f
Compare
|
thanks a lot for the PR, the code looks good to me, I left a couple comments! I will ask a second look by @regehr and @naveen-seth - do you guys think these rewrites will interfere with the legalization work? |
| LLVM: `CastInst::isEliminableCastPair` folds a `ZExt` followed by a `ZExt` | ||
| to the first cast. | ||
| https://github.com/llvm/llvm-project/blob/c536b0aa030474672e293dccdb27b97c36c4e1af/llvm/lib/IR/Instructions.cpp#L2922-L2967 -/ | ||
| private def zextw_zextb_pattern : Puddle.Pattern OpCode := |
There was a problem hiding this comment.
why is this definition private? (same for all the defs in this file)
There was a problem hiding this comment.
I'm not sure. I don't think there's a coherent pattern, but it seems like you only want to expose the compiled version for some combines. I've removed the "private" tag from all definitions now.
|
Upstream seems to make these optimizations during the legalization step, but I'd prefer landing this and to then move/revert this later once we have gotten further on legalization. |
Adds verified RISC-V combines:
roriw (xor (zextw x) (zextw y)), imm→roriw (xor x y), imm, removing redundant extensions in the ChaCha20 idiom while preserving shared full-width XOR uses.zextw (zextb x)→zextb x, including fixed-register retargeting.Includes correctness proofs and regression tests for matching, negative, shared-use, and fixed-register cases.