Re: [PATCH v2 03/15] unify simplify_lsr_or() & simplify_and_or_mask()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 17/08/18 22:17, Luc Van Oostenryck wrote:
> On Fri, Aug 17, 2018 at 08:45:02PM +0100, Ramsay Jones wrote:
>>
>>
>> On 16/08/18 23:12, Luc Van Oostenryck wrote:
>>> Doing a LSR(X, N) will drop the N right bits.
>>> So any simplification that can be made when using an AND clearing
>>> the right N bits can also be used on LSR (as if its first operand
>>> would first be implicitly be ANDed with such a mask).
>>>
>>> So, in order to not duplicate complex simplifications involving
>>> ANDs & ORs masks, merge these both function in a single one,
>>> using the mask corresponding to the operation.
>>>
>>> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
>>> ---
>>>  simplify.c | 56 ++++++++++++++++++++++--------------------------------
>>>  1 file changed, 23 insertions(+), 33 deletions(-)
>>>
>>> diff --git a/simplify.c b/simplify.c
>>> index ef98b205a..ce48b3a91 100644
>>> --- a/simplify.c
>>> +++ b/simplify.c
>>> @@ -546,6 +546,24 @@ undef:
>>>  	return NULL;
>>>  }
>>>  
>>> +static int simplify_mask_or_and(struct instruction *insn, unsigned long long mask,
>>> +	pseudo_t src, pseudo_t other)
>>> +{
>>> +	unsigned long long omask, nmask;
>>> +	pseudo_t src2 = src->def->src2;
>>> +
>>> +	if (!constant(src2))
>>> +		return 0;
>>> +	omask = src2->value;
>>> +	nmask = omask & mask;
>>> +	if (nmask != 0)
>>> +		return 0;
>>> +	// replace OP(((A & M') | B), C)
>>
>> Huh?, should that be OP(((A & M') | B), C) & M ?
>> and ...
>>> +	// by      OP(B, C)
>>
>> OP(B, C) & M ?
>>
>> confused.
> 
> Yes, sorry.
> All this merits much better documentation.
> OP(x, C) that I'm using here stand (or will stand) for either:
> * AND(x, M) and then mask = M
> * LSR(x, S) and then mask = (-1 << S)
> * SHL(x, S) and then mask = (-1 >> S)
> * TRUNC(x)  and then mask = $mask(newbitsize) = (1 << newbitsize) - 1

[Sorry for the delay; $LIFE is hectic at the moment.]

So, are you saying that the 'mask' given above is M' (or omask
in the code) and M is the function parameter 'mask'. ;-)

So src2->value in the above instructions are all 'mask' values
rather than (say) the shift count S? Hmm, so, Huh! :-D

ATB,
Ramsay Jones




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux