[PATCH 0/6] 'bits translation' simplification

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

 



This series allows the simplification of expressions like:
	if (val1 & 4)
		val2 |= 8;
into
	val2 |= (val1 & 4) << 1;

With a better if-conversion mechanism it also allows to optimize
	int translate_bits(int x)
	{
		int y = 0;
		if (x & 4)
			y |= 16;
		if (x & 8)
			y |= 32;
		return y;
	}

into this nice:
	translate_bits:
		and.32      %r2 <- %arg1, $12
		shl.32      %r5 <- %r2, $2
		ret.32      %r5

when applied on top of the previous 'factorization' series.

This series is available for review and testing at:
  git://git.kernel.org/pub/scm/devel/sparse/sparse-dev.git bit-trans

Luc Van Oostenryck (6):
  add testscases for 'bits translation' optimization
  factorize SEL(x, OP(y,z), y) into OP(SEL(x, z, 0), y)
  add helper is_power_of_2()
  add helper is_pow2()
  add log base 2 function: log2_exact()
  convert SEL(x & BIT1, BIT2, 0) into SHIFT(x & BIT1, S)

 bits.h                              | 12 ++++++
 simplify.c                          | 64 +++++++++++++++++++++++++++++
 validation/optim/fact-select01.c    | 25 +++++++++++
 validation/optim/select-and-shift.c | 17 ++++++++
 4 files changed, 118 insertions(+)
 create mode 100644 validation/optim/fact-select01.c
 create mode 100644 validation/optim/select-and-shift.c

-- 
2.29.2




[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