From: SourceForge.net <no...@so...> - 2012-06-22 11:17:52
|
Patches item #3507263, was opened at 2012-03-17 14:57 Message generated for change (Settings changed) made by spth You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=300599&aid=3507263&group_id=599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: z80 port Group: None >Status: Closed Resolution: None Priority: 5 Private: No Submitted By: Alexander Tsidaev (eltaron) Assigned to: Philipp Klaus Krause (spth) Summary: [z80] Peephole to replace "ld a,0" with "xor a" Initial Comment: Setting A register to zero is very widespread operation and I wonder why it performs such an unoptimized way. Replace it with "xor a" operation is better solution. This can be done in code but since we have useful peephole optimization engine we can use it. I'm not sure, may be this optimization can be applied to gbz80 and r2k, I never worked with such MCU's. ---------------------------------------------------------------------- Comment By: Philipp Klaus Krause (spth) Date: 2012-06-02 07:24 Message: Closing this item, since this has to be handled in the code generator (at least until we have a conditional for flags - and then the rules would have to be rewritten). In fact the code generator already does this in some places, though apparently not enough. Philipp ---------------------------------------------------------------------- Comment By: Erik Petrich (epetrich) Date: 2012-03-17 18:54 Message: I was just going to mention the problem with the carry bit being cleared, but I see Lee was quicker. This is not just a theoretical problem; for example, the following C code would generate a mangled result with this peephole rule: int x; void foo(void) { x = -x; } I think this is better handled in the code generator. ---------------------------------------------------------------------- Comment By: Lee Morrison (enigmalee) Date: 2012-03-17 18:19 Message: A new conditional would need to be created for the peephole rules that would check to see if the arithmetic flags (carry, zero, etc) were used (after the xor a,a) and before being set by another instruction (add, sub, rla, etc). The "ld a,#0" does not affect the flags, however "xor a,a" does. For example: rr a ld a,#0 rla a gives a different result than: rr a xor a,a rla a And there is currently no conditional available in the peephole optimizer to check if the arithmetic flags must be preserved. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=300599&aid=3507263&group_id=599 |