Ryan Taylor
2015-Jan-27 20:50 UTC
[LLVMdev] Making a CopyToReg/CopyFromReg into a zext/sext?
I have a CopyToReg that is moving a 16bit reg to a 32bit reg, it's currently being mapped out as a simple mov (not an ext), I would like to change that to an ext. It seemed that the SelDAG was the easiest and cleanest way to do this. I can change the mov to an extension MI in the .td file; however, I can't tell at that point whether it's a sext or a zext, so it seemed the SelDAG was the better place to fix this. Thanks. On Tue, Jan 27, 2015 at 3:38 PM, Matt Arsenault <Matthew.Arsenault at amd.com> wrote:> On 01/27/2015 12:28 PM, Ryan Taylor wrote: > > Thanks for getting back to me. > > So those nodes record if the type has already been expanded from a > narrower type. Can you elaborate how I could use these to help? Again, I'm > pretty unfamiliar with the SDNodes. > > Thanks. > > What is the problem you are trying to solve? These should allow > SimplifyDemandedBits type optimizations understand that your copy > implicitly extended the source > > > > > On Tue, Jan 27, 2015 at 3:22 PM, Matt Arsenault <Matthew.Arsenault at amd.com > > wrote: > >> On 01/27/2015 12:16 PM, Ryan Taylor wrote: >> >> I have a CopyToReg that is copying from different size types, what's >> the best way to change that to a zext or sext node based on signed or >> unsigned? >> >> I'm fairly unfamiliar with SelectionDAG process (outside of the docs on >> llvm website). >> >> It seems like I should be able to insert a custom hook using the >> register class to identify the type, potentially in ISelDAGToDag.cpp or is >> there a better place for this to be done? >> >> Thanks. >> >> >> It sounds to me like you are looking for the AssertSext / AssertZext >> nodes >> >> -Matt >> > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150127/67f2b164/attachment.html>
Matt Arsenault
2015-Jan-27 21:06 UTC
[LLVMdev] Making a CopyToReg/CopyFromReg into a zext/sext?
On 01/27/2015 12:50 PM, Ryan Taylor wrote:> I have a CopyToReg that is moving a 16bit reg to a 32bit reg, it's > currently being mapped out as a simple mov (not an ext), I would like > to change that to an ext. It seemed that the SelDAG was the easiest > and cleanest way to do this. > > I can change the mov to an extension MI in the .td file; however, I > can't tell at that point whether it's a sext or a zext, so it seemed > the SelDAG was the better place to fix this. >I guess that depends on where the CopyFromReg is coming from. If you need an ext instruction for the copy, it sounds like the CopyFromReg that makes this copy is a bug in the first place. -Matt
Ryan Taylor
2015-Jan-27 21:16 UTC
[LLVMdev] Fwd: Making a CopyToReg/CopyFromReg into a zext/sext?
So you don't think it's the CopyToReg, it's the CopyFromReg potentially. If that's the case it's still somewhat of the same issue right? I still need an ext instead of the Copy Node. On Tue, Jan 27, 2015 at 4:06 PM, Matt Arsenault <Matthew.Arsenault at amd.com> wrote:> On 01/27/2015 12:50 PM, Ryan Taylor wrote: > >> I have a CopyToReg that is moving a 16bit reg to a 32bit reg, it's >> currently being mapped out as a simple mov (not an ext), I would like to >> change that to an ext. It seemed that the SelDAG was the easiest and >> cleanest way to do this. >> >> I can change the mov to an extension MI in the .td file; however, I can't >> tell at that point whether it's a sext or a zext, so it seemed the SelDAG >> was the better place to fix this. >> >> I guess that depends on where the CopyFromReg is coming from. If you > need an ext instruction for the copy, it sounds like the CopyFromReg that > makes this copy is a bug in the first place. > > -Matt >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150127/ab7d333a/attachment.html>
Ryan Taylor
2015-Jan-27 21:23 UTC
[LLVMdev] Making a CopyToReg/CopyFromReg into a zext/sext?
Ok, thanks. Interchangeably makes sense, I'm not quite clear on the distinction. If I had a move class and MI for those registers in the InstrInfo.td file then it matches the MI based on the register classes of input, output. That doesn't help me with sign. So, can you point me in the general direction of where I should be looking to fix this? I thought they had a similar issue with the R600 trying to copy between different register types and they put in an explicit hook in ISelDAGToDAG? Thanks. On Tue, Jan 27, 2015 at 4:17 PM, Matt Arsenault <Matthew.Arsenault at amd.com> wrote:> On 01/27/2015 01:15 PM, Ryan Taylor wrote: > > So you don't think it's the CopyToReg, it's the CopyFromReg potentially. > If that's the case it's still somewhat of the same issue right? I still > need an ext instead of the Copy Node. > > I use them interchangeably. It depends on where it's coming from. If the > size is changing and the move doesn't implicitly extend, then the copy is > probably wrong and should copy to the same sized register and then create > the extension. > > > On Tue, Jan 27, 2015 at 4:06 PM, Matt Arsenault <Matthew.Arsenault at amd.com > > wrote: > >> On 01/27/2015 12:50 PM, Ryan Taylor wrote: >> >>> I have a CopyToReg that is moving a 16bit reg to a 32bit reg, it's >>> currently being mapped out as a simple mov (not an ext), I would like to >>> change that to an ext. It seemed that the SelDAG was the easiest and >>> cleanest way to do this. >>> >>> I can change the mov to an extension MI in the .td file; however, I >>> can't tell at that point whether it's a sext or a zext, so it seemed the >>> SelDAG was the better place to fix this. >>> >>> I guess that depends on where the CopyFromReg is coming from. If you >> need an ext instruction for the copy, it sounds like the CopyFromReg that >> makes this copy is a bug in the first place. >> >> -Matt >> > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150127/9ab31e00/attachment.html>
Matt Arsenault
2015-Jan-27 21:37 UTC
[LLVMdev] Making a CopyToReg/CopyFromReg into a zext/sext?
On 01/27/2015 01:23 PM, Ryan Taylor wrote:> Ok, thanks. Interchangeably makes sense, I'm not quite clear on the > distinction. If I had a move class and MI for those registers in the > InstrInfo.td file then it matches the MI based on the register classes > of input, output. That doesn't help me with sign. > > So, can you point me in the general direction of where I should be > looking to fix this? I thought they had a similar issue with the R600 > trying to copy between different register types and they put in an > explicit hook in ISelDAGToDAG? > > Thanks.CopyFromReg and CopyToReg aren't the same thing, I just started saying one instead of the other. I'm not sure what to do without knowing where / why the register copy is to a different sized register in the first place. I would expect that when you are creating such a CopyToReg, you would have the extension type and then CopyToReg of the extended type. R600 doesn't have any moves that could be confused with extensions. There are only 32-bit moves, and adjacent pairs of 32-bit registers can act as a 64-bit register for some instructions. Extensions are mostly just copies into a suitable register pair.