* [PATCH] Fix up r217118 - simplify_binary_operation_1 (PR rtl-optimization/63843)
@ 2014-11-18 22:08 Jakub Jelinek
2014-11-19 8:49 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2014-11-18 22:08 UTC (permalink / raw)
To: Richard Biener, Eric Botcazou; +Cc: gcc-patches
Hi!
The case ASHIFTRT: which is meant for this optimization is preceeded by
/* FALLTHRU */ from ROTATE cases, which can't be optimized this way.
Thus, this patch limits this optimization to ASHIFTRT.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2014-11-18 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/63843
* simplify-rtx.c (simplify_binary_operation_1) <case ASHIFTRT>: For
optimization of ashiftrt of subreg of lshiftrt, check that code
is ASHIFTRT.
* gcc.c-torture/execute/pr63843.c: New test.
--- gcc/simplify-rtx.c.jj 2014-11-18 10:17:01.000000000 +0100
+++ gcc/simplify-rtx.c 2014-11-18 13:44:26.727792683 +0100
@@ -3118,10 +3118,11 @@ simplify_binary_operation_1 (enum rtx_co
(subreg:M1 (ashiftrt:M2 (reg:M2)
(const_int <c1 + c2>))
<low_part>). */
- if (!VECTOR_MODE_P (mode)
+ if (code == ASHIFTRT
+ && !VECTOR_MODE_P (mode)
&& SUBREG_P (op0)
&& CONST_INT_P (op1)
- && (GET_CODE (SUBREG_REG (op0)) == LSHIFTRT)
+ && GET_CODE (SUBREG_REG (op0)) == LSHIFTRT
&& !VECTOR_MODE_P (GET_MODE (SUBREG_REG (op0)))
&& CONST_INT_P (XEXP (SUBREG_REG (op0), 1))
&& (GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (op0)))
--- gcc/testsuite/gcc.c-torture/execute/pr63843.c.jj 2014-11-18 13:43:45.417544096 +0100
+++ gcc/testsuite/gcc.c-torture/execute/pr63843.c 2014-11-18 13:43:32.000000000 +0100
@@ -0,0 +1,31 @@
+/* PR rtl-optimization/63843 */
+
+static inline __attribute__ ((always_inline))
+unsigned short foo (unsigned short v)
+{
+ return (v << 8) | (v >> 8);
+}
+
+unsigned short __attribute__ ((noinline, noclone, hot))
+bar (unsigned char *x)
+{
+ unsigned int a;
+ unsigned short b;
+ __builtin_memcpy (&a, &x[0], sizeof (a));
+ a ^= 0x80808080U;
+ __builtin_memcpy (&x[0], &a, sizeof (a));
+ __builtin_memcpy (&b, &x[2], sizeof (b));
+ return foo (b);
+}
+
+int
+main ()
+{
+ unsigned char x[8] = { 0x01, 0x01, 0x01, 0x01 };
+ if (__CHAR_BIT__ == 8
+ && sizeof (short) == 2
+ && sizeof (int) == 4
+ && bar (x) != 0x8181U)
+ __builtin_abort ();
+ return 0;
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix up r217118 - simplify_binary_operation_1 (PR rtl-optimization/63843)
2014-11-18 22:08 [PATCH] Fix up r217118 - simplify_binary_operation_1 (PR rtl-optimization/63843) Jakub Jelinek
@ 2014-11-19 8:49 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2014-11-19 8:49 UTC (permalink / raw)
To: Jakub Jelinek, Eric Botcazou; +Cc: gcc-patches
On November 18, 2014 10:59:28 PM CET, Jakub Jelinek <jakub@redhat.com> wrote:
>Hi!
>
>The case ASHIFTRT: which is meant for this optimization is preceeded by
>/* FALLTHRU */ from ROTATE cases, which can't be optimized this way.
>Thus, this patch limits this optimization to ASHIFTRT.
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
OK.
Thanks,
Richard.
>2014-11-18 Jakub Jelinek <jakub@redhat.com>
>
> PR rtl-optimization/63843
> * simplify-rtx.c (simplify_binary_operation_1) <case ASHIFTRT>: For
> optimization of ashiftrt of subreg of lshiftrt, check that code
> is ASHIFTRT.
>
> * gcc.c-torture/execute/pr63843.c: New test.
>
>--- gcc/simplify-rtx.c.jj 2014-11-18 10:17:01.000000000 +0100
>+++ gcc/simplify-rtx.c 2014-11-18 13:44:26.727792683 +0100
>@@ -3118,10 +3118,11 @@ simplify_binary_operation_1 (enum rtx_co
> (subreg:M1 (ashiftrt:M2 (reg:M2)
> (const_int <c1 + c2>))
> <low_part>). */
>- if (!VECTOR_MODE_P (mode)
>+ if (code == ASHIFTRT
>+ && !VECTOR_MODE_P (mode)
> && SUBREG_P (op0)
> && CONST_INT_P (op1)
>- && (GET_CODE (SUBREG_REG (op0)) == LSHIFTRT)
>+ && GET_CODE (SUBREG_REG (op0)) == LSHIFTRT
> && !VECTOR_MODE_P (GET_MODE (SUBREG_REG (op0)))
> && CONST_INT_P (XEXP (SUBREG_REG (op0), 1))
> && (GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (op0)))
>--- gcc/testsuite/gcc.c-torture/execute/pr63843.c.jj 2014-11-18
>13:43:45.417544096 +0100
>+++ gcc/testsuite/gcc.c-torture/execute/pr63843.c 2014-11-18
>13:43:32.000000000 +0100
>@@ -0,0 +1,31 @@
>+/* PR rtl-optimization/63843 */
>+
>+static inline __attribute__ ((always_inline))
>+unsigned short foo (unsigned short v)
>+{
>+ return (v << 8) | (v >> 8);
>+}
>+
>+unsigned short __attribute__ ((noinline, noclone, hot))
>+bar (unsigned char *x)
>+{
>+ unsigned int a;
>+ unsigned short b;
>+ __builtin_memcpy (&a, &x[0], sizeof (a));
>+ a ^= 0x80808080U;
>+ __builtin_memcpy (&x[0], &a, sizeof (a));
>+ __builtin_memcpy (&b, &x[2], sizeof (b));
>+ return foo (b);
>+}
>+
>+int
>+main ()
>+{
>+ unsigned char x[8] = { 0x01, 0x01, 0x01, 0x01 };
>+ if (__CHAR_BIT__ == 8
>+ && sizeof (short) == 2
>+ && sizeof (int) == 4
>+ && bar (x) != 0x8181U)
>+ __builtin_abort ();
>+ return 0;
>+}
>
> Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-19 7:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-18 22:08 [PATCH] Fix up r217118 - simplify_binary_operation_1 (PR rtl-optimization/63843) Jakub Jelinek
2014-11-19 8:49 ` Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).