Transforms and(fcmp(a, b), fcmp(c, d)) into fccmp(fcmp(a, b), c, d)
Issue link: https://github.com/llvm/llvm-project/issues/60819
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thank you for fixing up the other test changes, this is looking pretty good. I have some small changes to suggest.
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | ||
---|---|---|
17158–17177 | This doesn't quite match the LLVM style guide. You can try running git-clang-format HEAD^ to fix it automatically. If that doesn't work, you can re-style the code manually to make it look like the rest of the file. | |
17158–17177 | I think this code would be nice to have in a function, perhaps named something like performANDSETCCCombine? Some comments about the transformation it performs (turning and(fcmp(a, b), fcmp(c, d)) into fccmp(fcmp(a, b), c, d)) would be good too. |
Thanks! Just a few more clean-up changes from me and I'll add another reviewer for a wider audience.
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | ||
---|---|---|
17110 | This could be moved to be just before the line it's used on. | |
17111 | This could be moved to be just before where's it's used and AArch64CC seems like a verbose name so maybe just CC is enough. | |
17112 | Same story with Cmp as it could be moved to be just before where it's set, | |
17128–17133 | This can just return the value from DAG.getNode(...) | |
17135 | We'll need a default return of SDValue() in case the if statements above don't pass. |
llvm/test/CodeGen/AArch64/andcompare.ll | ||
---|---|---|
2525 | Oh and a more explaining function name would be good, something like and_fcmp? |
Just one small change, but otherwise it looks good to me! I can commit this for you once you've moved the comment above the function, and then we can see about getting you commit access yourself.
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | ||
---|---|---|
17133 | I think this comment is quite useful and would be good to have on the line above the function definition. |
llvm/test/CodeGen/AArch64/select_fmf.ll | ||
---|---|---|
15–17 ↗ | (On Diff #539834) | This change doesn't look beneficial because it adds extra instructions that aren't really needed. I think we'll need to find a way of restricting the code you've written to not transform this example. You can try looking at the debug output with the -print-after-all option added to llc to see what is different for this test case and the one you added. While testing you can copy this test file and remove everything but the two functions we're interested in to reduce the debug output when you run llc on it. |
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | ||
---|---|---|
17128 | Have we already checked for and before calling emitConjunction ? |
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | ||
---|---|---|
17142–17143 | I think these may be better as DAG.getConstant(0, DL, VT), as opposed to AArch64::WZR / AArch64::XZR. They should get converted to the same thing eventually, but having zero constant's will be easier for the rest of DAG to reason about. |
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | ||
---|---|---|
17111 | I kept it AArch64CC because CC is giving the error. | |
17121 | Yep! We can update it in the future so that it works with the codegen. | |
17128 | Sorry, I didn't get what you are trying to ask? Can you please elaborate little bit. | |
17142–17143 | Yup! I tried that too but it was generating this instruction "cset w0, ne" instead of this one "cset w0, vs". | |
17158–17177 | Okay! I will try to do it asap. |
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | ||
---|---|---|
17142–17143 | Is that with something like this? return DAG.getNode(AArch64ISD::CSINC, DL, VT, DAG.getConstant(0, DL, VT), DAG.getConstant(0, DL, VT), DAG.getConstant(InvertedCC, DL, MVT::i32), Cmp); |
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | ||
---|---|---|
17142–17143 | Ohh! yes it is correct. Earlier I have replaced DAG.getConstant(InvertedCC, DL, MVT::i32), Cmp); with DAG.getConstant(0, DL, VT) that's why it was not working. |
Thanks David. I can commit this for you if you'd like @ipriyanshi1708 . Shall I use the same email address and name as your previous commit?
Some comments, about what transformation this function performs, would be useful.