From 6675c1b7cc50da69fc484569d95c3002bc0552d1 Mon Sep 17 00:00:00 2001 From: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Fri, 10 Dec 2010 12:43:45 +0000 Subject: [PATCH] PR rtl-optimization/46865 * rtl.c (rtx_equal_p_cb, rtx_equal_p): For last operand of ASM_OPERANDS and ASM_INPUT if integers are different, call locator_eq. * jump.c (rtx_renumbered_equal_p): Likewise. * gcc.target/i386/pr46865-1.c: New test. * gcc.target/i386/pr46865-2.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167686 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 +++++ gcc/jump.c | 8 ++++++- gcc/rtl.c | 20 ++++++++++++++++- gcc/testsuite/ChangeLog | 4 +++ gcc/testsuite/gcc.target/i386/pr46865-1.c | 31 ++++++++++++++++++++++++++++ gcc/testsuite/gcc.target/i386/pr46865-2.c | 32 +++++++++++++++++++++++++++++ 6 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr46865-1.c create mode 100644 gcc/testsuite/gcc.target/i386/pr46865-2.c diff --git a/gcc/jump.c b/gcc/jump.c index 928bb81..b85326a 100644 --- a/gcc/jump.c +++ b/gcc/jump.c @@ -1727,7 +1727,13 @@ rtx_renumbered_equal_p (const_rtx x, const_rtx y) case 'i': if (XINT (x, i) != XINT (y, i)) - return 0; + { + if (((code == ASM_OPERANDS && i == 6) + || (code == ASM_INPUT && i == 1)) + && locator_eq (XINT (x, i), XINT (y, i))) + break; + return 0; + } break; case 't': diff --git a/gcc/rtl.c b/gcc/rtl.c index 6f34979..878446c 100644 --- a/gcc/rtl.c +++ b/gcc/rtl.c @@ -431,7 +431,15 @@ rtx_equal_p_cb (const_rtx x, const_rtx y, rtx_equal_p_callback_function cb) case 'n': case 'i': if (XINT (x, i) != XINT (y, i)) - return 0; + { +#ifndef GENERATOR_FILE + if (((code == ASM_OPERANDS && i == 6) + || (code == ASM_INPUT && i == 1)) + && locator_eq (XINT (x, i), XINT (y, i))) + break; +#endif + return 0; + } break; case 'V': @@ -555,7 +563,15 @@ rtx_equal_p (const_rtx x, const_rtx y) case 'n': case 'i': if (XINT (x, i) != XINT (y, i)) - return 0; + { +#ifndef GENERATOR_FILE + if (((code == ASM_OPERANDS && i == 6) + || (code == ASM_INPUT && i == 1)) + && locator_eq (XINT (x, i), XINT (y, i))) + break; +#endif + return 0; + } break; case 'V': diff --git a/gcc/testsuite/gcc.target/i386/pr46865-1.c b/gcc/testsuite/gcc.target/i386/pr46865-1.c new file mode 100644 index 0000000..220a1c0 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr46865-1.c @@ -0,0 +1,31 @@ +/* PR rtl-optimization/46865 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern unsigned long f; + +#define m1(f) \ + if (f & 1) \ + asm volatile ("nop /* asmnop */\n"); \ + else \ + asm volatile ("nop /* asmnop */\n"); + +#define m2(f) \ + if (f & 1) \ + asm volatile ("nop /* asmnop */\n" : : "i" (6) : "cx"); \ + else \ + asm volatile ("nop /* asmnop */\n" : : "i" (6) : "cx"); + +void +foo (void) +{ + m1 (f); +} + +void +bar (void) +{ + m2 (f); +} + +/* { dg-final { scan-assembler-times "asmnop" 2 } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr46865-2.c b/gcc/testsuite/gcc.target/i386/pr46865-2.c new file mode 100644 index 0000000..4a91f7c --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr46865-2.c @@ -0,0 +1,32 @@ +/* PR rtl-optimization/46865 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -save-temps" } */ + +extern unsigned long f; + +#define m1(f) \ + if (f & 1) \ + asm volatile ("nop /* asmnop */\n"); \ + else \ + asm volatile ("nop /* asmnop */\n"); + +#define m2(f) \ + if (f & 1) \ + asm volatile ("nop /* asmnop */\n" : : "i" (6) : "cx"); \ + else \ + asm volatile ("nop /* asmnop */\n" : : "i" (6) : "cx"); + +void +foo (void) +{ + m1 (f); +} + +void +bar (void) +{ + m2 (f); +} + +/* { dg-final { scan-assembler-times "asmnop" 2 } } */ +/* { dg-final { cleanup-saved-temps } } */ -- 1.7.3.4