This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH GCC]Support BIT_AND_EXPR in scalar evolution


Hi,
Type conversion from integer to smaller unsigned type could be transformed into BIT_AND_EXPR in compilation.  For example,
  int i;
  for (i = 0; i < n; i++)
    {
      unsigned char uc = (unsigned char) i;  // transformed into X = i && 255, in which both X and i are of int type.
      b[uc] = 0;
    }
X here could a valid SCEV if we can prove that loop doesn't iterate more than 255 times.  In other words, if 'i' is SCEV and its value is in the range of representable set of type "unsigned char".  This information could be available with -faggressive-loop-optimizations.
This patch adds support for BIT_AND_EXPR in scalar evolution to handle such cases, as well as two new tests.

Bootstrap and test on x86_64 & AArch64.  Is it OK?

Thanks,
bin

2016-03-24  Bin Cheng  <bin.cheng@arm.com>

	* tree-scalar-evolution.c (interpret_rhs_expr): Handle BIT_AND_EXPR.

gcc/testsuite/ChangeLog
2016-03-24  Bin Cheng  <bin.cheng@arm.com>

	* gcc.dg/tree-ssa/scev-11.c: New test.
	* gcc.dg/tree-ssa/scev-12.c: New test.

Attachment: scev-bit_and_expr-20160324.txt
Description: scev-bit_and_expr-20160324.txt


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]