[combine][v2] Canonicalise (r + r) to (r << 1) to aid recognition

PR rtl-optimization/68651
	* combine.c (combine_simplify_rtx): Canonicalize x + x into
	x << 1.

	* gcc.target/aarch64/pr68651_1.c: New test.

From-SVN: r232077
This commit is contained in:
Kyrylo Tkachov 2016-01-05 16:06:06 +00:00 committed by Kyrylo Tkachov
parent c589e97563
commit a0866effcd
4 changed files with 34 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2016-01-05 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
PR rtl-optimization/68651
* combine.c (combine_simplify_rtx): Canonicalize x + x into
x << 1.
2016-01-05 Nathan Sidwell <nathan@acm.org>
* alias.c (compare_base_decls): Use symtab_node::get.

View File

@ -5895,6 +5895,13 @@ combine_simplify_rtx (rtx x, machine_mode op0_mode, int in_dest,
|| XEXP (temp, 1) != XEXP (x, 0)))))
return temp;
}
/* Canonicalize x + x into x << 1. */
if (GET_MODE_CLASS (mode) == MODE_INT
&& rtx_equal_p (XEXP (x, 0), XEXP (x, 1))
&& !side_effects_p (XEXP (x, 0)))
return simplify_gen_binary (ASHIFT, mode, XEXP (x, 0), const1_rtx);
break;
case MINUS:

View File

@ -1,3 +1,8 @@
2016-01-05 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
PR rtl-optimization/68651
* gcc.target/aarch64/pr68651_1.c: New test.
2016-01-05 David Malcolm <dmalcolm@redhat.com>
PR c/69122

View File

@ -0,0 +1,16 @@
/* { dg-do compile } */
/* { dg-options "-O2 -mcpu=cortex-a53" } */
int
foo (int x)
{
return (x * 2) & 65535;
}
/* { dg-final { scan-assembler "ubfiz\tw\[0-9\]*, w\[0-9\]*.*\n" } } */
int
bar (int x, int y)
{
return (x * 2) | y;
}
/* { dg-final { scan-assembler "orr\tw\[0-9\]*, w\[0-9\]*, w\[0-9\]*, lsl 1.*\n" } } */