|
From: Patrick J. L. <lop...@gm...> - 2012-11-05 01:32:25
|
On Fri, Oct 19, 2012 at 12:24 PM, Lok Kwong Yan <lo...@sy...> wrote: > > 3. In the case of BSF, what about PCast( BSF(va) <= BSF(a) )? I ended up using this approach. I have added two new attachments to <https://bugs.kde.org/show_bug.cgi?id=308627>. They re-base Julian's old patches for VEX and memcheck, respectively, to current SVN. I would appreciate a code review and also some advice. This new VEX+memcheck does perform better validity bit propagation for Iop_Ctz32 and Iop_Ctz64. But guest_amd64_to_IR contains the following unfortunate code in dis_bs_E_G (which handles BSF): /* Generate an 8-bit expression which is zero iff the original is zero, and nonzero otherwise */ assign( src8, unop(Iop_1Uto8, binop(Iop_CmpNE64, mkexpr(src64), mkU64(0))) ); This emits a CmpNE64 instruction against the BSF argument. Later that result goes to IRExpr_Mux0X() to handle the semantics for a zero input. The net result is that memcheck thinks the entire bsfl result is always invalid if any input bits are invalid, even though Iop_Ctz32 and Iop_Ctz64 now propagate the validity bits correctly. What is the right way to handle this? I have confirmed that this is the problem by forcing memcheck to call expensiveCmpEQorNE() unconditionally for Iop_CmpNE64. This allows it to see that any valid "1" bit means the value is not zero, and this actually lets my "bsfl" test case pass. Thanks. - Pat |