Re: [PATCH 09/13] simplify SETNE(TRUNC(x,N),{0,1})

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

 




On 04/08/18 21:35, Luc Van Oostenryck wrote:
> Convert the OP_TRUNC into an OP_AND with the appropriate mask.
> This a greater chance to simplify with previous instructions
> and to correspond to a register-size operand.
> 
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
> ---
>  simplify.c                      | 17 +++++++++++++++++
>  validation/optim/trunc-setne0.c |  1 -
>  2 files changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/simplify.c b/simplify.c
> index ae53e7ae7..911bfde7e 100644
> --- a/simplify.c
> +++ b/simplify.c
> @@ -690,6 +690,7 @@ static int simplify_seteq_setne(struct instruction *insn, long long value)
>  {
>  	pseudo_t old = insn->src1;
>  	struct instruction *def;
> +	unsigned osize;
>  	int inverse;
>  	int opcode;
>  
> @@ -749,6 +750,22 @@ static int simplify_seteq_setne(struct instruction *insn, long long value)
>  		//	setne.1 %s <- %a, $0
>  		// and same for setne/eq ... 0/1
>  		return replace_pseudo(insn, &insn->src1, def->src);
> +	case OP_TRUNC:
> +		if (nbr_users(old) > 1)
> +			break;
> +		// convert
> +		//	trunc.n	%s <- (o) %a
> +		//	setne.m %r <- %s, $0
> +		// into:
> +		//	and.o	%s <- %a, $((1 << o) - 1)
> +		//	setne.m %r <- %a, $0

s/%a/%s/ ?

ATB,
Ramsay Jones

> +		// and same for setne/eq ... 0/1
> +		osize = def->size;
> +		def->opcode = OP_AND;
> +		def->type = def->orig_type;
> +		def->size = def->type->bit_size;
> +		def->src2 = value_pseudo(bits_mask(osize));
> +		return REPEAT_CSE;
>  	}
>  	return 0;
>  }
> diff --git a/validation/optim/trunc-setne0.c b/validation/optim/trunc-setne0.c
> index 16f99a88c..878c05fa6 100644
> --- a/validation/optim/trunc-setne0.c
> +++ b/validation/optim/trunc-setne0.c
> @@ -13,7 +13,6 @@ unsigned int foo(struct s x)
>  /*
>   * check-name: trunc-setne0
>   * check-command: test-linearize -Wno-decl $file
> - * check-known-to-fail
>   *
>   * check-output-ignore
>   * check-output-contains: and\\.
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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