On 10/19/2011 05:33 PM, Richard Guenther wrote:
> On Wed, Oct 19, 2011 at 10:23 AM, Tom de Vries <tom_devr...@mentor.com> wrote:
>> Richard,
>>
>> For the example from the PR, -ftree-tail-merge discovers that blocks 6 and 7 
>> are
>> equal, removes block 7 and redirects the outgoing edge of it's predecessor 
>> block
>> 11 to block 6.
>>
>> Block 6 contains a phi, which after redirecting the edge from block 11 looks
>> like this:
>> ...
>> .MEM_54 = PHI <.MEM_27(18), .MEM_26(17), (11)>
>> ...
>>
>> Since update_vops is false, TODO_update_ssa_only_virtuals will be run
>> and -ftree-tail-merge doesn't update the phi.
>>
>> However during cleanup_tree_cfg (which is done before updating the ssa),
>> phi_alternatives_equal is called which asserts that the phi arguments are 
>> defined.
>>
>> The patch fixes the ICE by setting the empty phi argument to .MEM.
>>
>> bootstrapped and reg-tested on x86_64.
>>
>> Ok for trunk?
> 
> Ok.
> 

Committed test-case.

Thanks,
- Tom

2011-11-02  Tom de Vries  <t...@codesourcery.com>

        PR tree-optimization/50769
        * gfortran.dg/pr50769.f90: New test.
Index: gcc/testsuite/gfortran.dg/pr50769.f90
===================================================================
--- /dev/null (new file)
+++ gcc/testsuite/gfortran.dg/pr50769.f90 (revision 0)
@@ -0,0 +1,30 @@
+! { dg-do compile }
+! { dg-options "-O2 -ftree-tail-merge -fno-delete-null-pointer-checks -fno-guess-branch-probability" }
+!
+! based on testsuite/gfortran.dg/alloc_comp_optional_1.f90,
+! which was contributed by David Kinniburgh <davidkinnibu...@yahoo.co.uk>
+!
+program test_iso
+  type ivs
+     character(LEN=1), dimension(:), allocatable :: chars
+  end type ivs
+  type(ivs) :: v_str
+  integer :: i
+  call foo(v_str, i)
+  if (v_str%chars(1) .ne. "a") call abort
+  if (i .ne. 0) call abort
+  call foo(flag = i)
+  if (i .ne. 1) call abort
+contains
+  subroutine foo (arg, flag)
+    type(ivs), optional, intent(out) :: arg
+    integer :: flag
+    if (present(arg)) then
+      arg = ivs([(char(i+96), i = 1,10)])
+      flag = 0
+    else
+      flag = 1
+    end if
+  end subroutine
+end
+

Reply via email to