From 404b86eda8700e30a71b51cddada39b57e13d28a Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 23 Mar 2015 16:31:59 +0100 Subject: [PATCH] re PR target/65504 (select case with strings and -fgcse -O) PR target/65504 * config/i386/i386.c (ix86_copy_addr_to_reg): Set REG_POINTER on the pseudo. (expand_set_or_movmem_prologue_epilogue_by_misaligned_moves): Set REG_POINTER on *destptr after adjusting it for prologue size. * gfortran.dg/pr65504.f90: New test. From-SVN: r221597 --- gcc/ChangeLog | 8 +++++++- gcc/config/i386/i386.c | 17 ++++++++++++---- gcc/testsuite/ChangeLog | 5 ++++- gcc/testsuite/gfortran.dg/pr65504.f90 | 28 +++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr65504.f90 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d6603636c5b..a5eb8c49630 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,10 @@ -2014-03-23 Jakub Jelinek +2015-03-23 Jakub Jelinek + + PR target/65504 + * config/i386/i386.c (ix86_copy_addr_to_reg): Set REG_POINTER + on the pseudo. + (expand_set_or_movmem_prologue_epilogue_by_misaligned_moves): Set + REG_POINTER on *destptr after adjusting it for prologue size. PR ipa/65521 * ipa-icf.c (sem_item::update_hash_by_addr_refs): Hash diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 82a48482be6..22bc81f165a 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -23457,12 +23457,19 @@ counter_mode (rtx count_exp) static rtx ix86_copy_addr_to_reg (rtx addr) { + rtx reg; if (GET_MODE (addr) == Pmode || GET_MODE (addr) == VOIDmode) - return copy_addr_to_reg (addr); + { + reg = copy_addr_to_reg (addr); + REG_POINTER (reg) = 1; + return reg; + } else { gcc_assert (GET_MODE (addr) == DImode && Pmode == SImode); - return gen_rtx_SUBREG (SImode, copy_to_mode_reg (DImode, addr), 0); + reg = copy_to_mode_reg (DImode, addr); + REG_POINTER (reg) = 1; + return gen_rtx_SUBREG (SImode, reg, 0); } } @@ -24354,6 +24361,8 @@ expand_set_or_movmem_prologue_epilogue_by_misaligned_moves (rtx destmem, rtx src *destptr = expand_simple_binop (GET_MODE (*destptr), PLUS, *destptr, GEN_INT (prolog_size), NULL_RTX, 1, OPTAB_DIRECT); + if (REG_P (*destptr) && REG_P (saveddest) && REG_POINTER (saveddest)) + REG_POINTER (*destptr) = 1; *destptr = expand_simple_binop (GET_MODE (*destptr), AND, *destptr, GEN_INT (-desired_align), *destptr, 1, OPTAB_DIRECT); @@ -24363,8 +24372,8 @@ expand_set_or_movmem_prologue_epilogue_by_misaligned_moves (rtx destmem, rtx src saveddest, 1, OPTAB_DIRECT); /* Adjust srcptr and count. */ if (!issetmem) - *srcptr = expand_simple_binop (GET_MODE (*srcptr), MINUS, *srcptr, saveddest, - *srcptr, 1, OPTAB_DIRECT); + *srcptr = expand_simple_binop (GET_MODE (*srcptr), MINUS, *srcptr, + saveddest, *srcptr, 1, OPTAB_DIRECT); *count = expand_simple_binop (GET_MODE (*count), PLUS, *count, saveddest, *count, 1, OPTAB_DIRECT); /* We copied at most size + prolog_size. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d3958f67124..4e041b104b9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,4 +1,7 @@ -2014-03-23 Jakub Jelinek +2015-03-23 Jakub Jelinek + + PR target/65504 + * gfortran.dg/pr65504.f90: New test. PR ipa/65521 * gcc.dg/pr65521.c: New test. diff --git a/gcc/testsuite/gfortran.dg/pr65504.f90 b/gcc/testsuite/gfortran.dg/pr65504.f90 new file mode 100644 index 00000000000..3860422b322 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr65504.f90 @@ -0,0 +1,28 @@ +! PR target/65504 +! { dg-do run } + +program pr65504 + implicit none + type :: T + character (len=256) :: a + character (len=256) :: b + end type T + type (T) :: c + type (T) :: d + c = foo ("test") + d = foo ("test") + if (trim(c%b) .ne. "foo") call abort + contains + type (T) function foo (x) result (v) + character(len=*), intent(in) :: x + select case (x) + case ("test") + v%b = 'foo' + case ("bazx") + v%b = 'barx' + case default + print *, "unknown" + stop + end select + end function foo +end program pr65504 -- 2.30.2