From: wolfgang.thaller@gmx.net Date: Thu, 7 Dec 2006 13:17:21 +0000 (+0000) Subject: Tell the NCG that XOR foo, foo does *not* read foo X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=bbb0e7f311398fcdca3aee729fb2419a8d95dc1a Tell the NCG that XOR foo, foo does *not* read foo On x86[-64], MachCodeGen uses the old XOR trick to zero a register. This patch makes regUsage not list the register as an input in this case. Listing the register as an input for the instruction could make it appear like an unitialised value, which is bad because unitialised values can cause the register allocator to panic (at least in the presence of a loop). --- diff --git a/compiler/nativeGen/RegAllocInfo.hs b/compiler/nativeGen/RegAllocInfo.hs index df74218..d526641 100644 --- a/compiler/nativeGen/RegAllocInfo.hs +++ b/compiler/nativeGen/RegAllocInfo.hs @@ -156,6 +156,8 @@ regUsage instr = case instr of IDIV sz op -> mkRU (eax:edx:use_R op) [eax,edx] AND sz src dst -> usageRM src dst OR sz src dst -> usageRM src dst + XOR sz (OpReg src) (OpReg dst) + | src == dst -> mkRU [] [dst] XOR sz src dst -> usageRM src dst NOT sz op -> usageM op NEGI sz op -> usageM op