>>Note that the isCommutable flag is only really useful for two-addressinstructions. If the two inputs are not constrained, nothing is really won by swapping them. Ahh i see, good to know that.>> Does the -view-*-dags output look correct?They do look correct, there are three Xmul_lohi blocks, one returns the low part copied into R14 and the rest of combinations get added and merged into R15. Here is my selectionDAG code, i used X86's MUL code and adapted it to my target: case ISD::SMUL_LOHI: case ISD::UMUL_LOHI: { SDValue Op1 = N->getOperand(0); SDValue Op2 = N->getOperand(1); unsigned LoReg = R0, HiReg = R1; unsigned Opc = MULRdRr; SDValue InFlag = SDValue(CurDAG->getMachineNode(Opc, dl, MVT::Flag, Op1, Op2), 0); // Copy the low half of the result, if it is needed. if (!SDValue(N, 0).use_empty()) { SDValue Result CurDAG->getCopyFromReg(CurDAG->getEntryNode(), dl, LoReg, NVT, InFlag); InFlag = Result.getValue(2); ReplaceUses(SDValue(N, 0), Result); } // Copy the high half of the result, if it is needed. if (!SDValue(N, 1).use_empty()) { SDValue Result CurDAG->getCopyFromReg(CurDAG->getEntryNode(), dl, HiReg, NVT, InFlag); InFlag = Result.getValue(2); ReplaceUses(SDValue(N, 1), Result); } return NULL; } ISD::MUL is set to be expanded. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100910/e7572deb/attachment.html>
Hello Jakob, i've been trying different things like adding customized code for the multiplication instruction instead of letting LLVM expand it however it produced exactly the same code in all the alternatives i tested. Please let me know when you have time if there's a way to improve the emitted code or if it's a missed optimization. I dont know in which other ways i could improve this since it's so basic code. As a side note, it would be great if you could answer some doubts i wrote in the "Register design decision for backend" thread. Thanks for your help. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100911/c08193b7/attachment.html>
On Sep 11, 2010, at 10:02 AM, Borja Ferrer wrote:> Hello Jakob, i've been trying different things like adding customized code for the multiplication instruction instead of letting LLVM expand it however it produced exactly the same code in all the alternatives i tested. > Please let me know when you have time if there's a way to improve the emitted code or if it's a missed optimization. I dont know in which other ways i could improve this since it's so basic code.I gave you some pointers to get you started on your own analysis of this. Take a look at the DAGs and the scheduling. I don't want to take away this opportunity for you to learn more about how the LLVM code generator works. /jakob
Maybe Matching Threads
- [LLVMdev] Possible missed optimization? 2.0
- [LLVMdev] Issue with Machine Verifier and earlyclobber
- [LLVMdev] LLVM ERROR: ran out of registers during register allocation
- [LLVMdev] Issue with Machine Verifier and earlyclobber
- [LLVMdev] LLVM ERROR: ran out of registers during register allocation