Martin J. O'Riordan
2014-Dec-22 15:44 UTC
[LLVMdev] Marking implicit registers as "trashed"
I am working on some optimizations for our VLIW processor; one ALU performs 32-bit operations, while another performs 8-, 16- or 32-bit operations. Sometimes it is useful for the 32-bit ALU to perform 8- or 16-bit operations such as ADD, SUB, SHL, AND, etc. that are not dependent on the additional 24-bits, but because it is 32-bit ALU, the condition codes are updated. When this is being used to offload the 8- and 16-bit arithmetic, the actual outcome of these condition codes is irrelevant, and it is important that later operations do not make conditional or predicated decisions based on their values. The 'Uses = [...]' and 'Defs = [...]', but I would like something like 'Trash = [...]' to say that the register is changed, but the change is meaningless. Does anyone have any suggestions as to how I should approach this kind of semantic? Thanks, MartinO Martin O'Riordan, Movidius Ltd.
> The 'Uses = [...]' and 'Defs = [...]', but I would like something like > 'Trash = [...]' to say that the register is changed, but the change is > meaningless. > > Does anyone have any suggestions as to how I should approach this kind of > semantic?This is expressed by a Def that isn't actually used by anything, usually expressed <def,dead> in debug printouts. So as long as you don't try to make use of those flags during ISel you should be fine. For example, most x86 instructions set flags so when you compile this with "llc -print-after-all": define i32 @foo(i32 %l, i32 %r) { %res = mul i32 %l, %r ret i32 %res } You'll see an instruction like this: %vreg2<def,tied1> = IMUL32rr %vreg2<tied0>, %vreg1, %EFLAGS<imp-def,dead> Cheers. Tim.
Martin J. O'Riordan
2014-Dec-23 10:38 UTC
[LLVMdev] Marking implicit registers as "trashed"
Thanks Tim. Yes, I guess I was a bit nervous that the flags might be implicitly used "as-if" they were valid. All the best, MartinO -----Original Message----- From: Tim Northover [mailto:t.p.northover at gmail.com] Sent: 22 December 2014 17:18 To: Martin J. O'Riordan Cc: LLVM Developers Mailing List Subject: Re: [LLVMdev] Marking implicit registers as "trashed"> The 'Uses = [...]' and 'Defs = [...]', but I would like something like > 'Trash = [...]' to say that the register is changed, but the change is > meaningless. > > Does anyone have any suggestions as to how I should approach this kind > of semantic?This is expressed by a Def that isn't actually used by anything, usually expressed <def,dead> in debug printouts. So as long as you don't try to make use of those flags during ISel you should be fine. For example, most x86 instructions set flags so when you compile this with "llc -print-after-all": define i32 @foo(i32 %l, i32 %r) { %res = mul i32 %l, %r ret i32 %res } You'll see an instruction like this: %vreg2<def,tied1> = IMUL32rr %vreg2<tied0>, %vreg1, %EFLAGS<imp-def,dead> Cheers. Tim.