------- Additional Comments From uweigand at gcc dot gnu dot org  2005-01-15 
00:45 -------
This is caused by instruction scheduling not noticing a dependency,
apparently because alias sets are set up incorrectly.

At the end of the tree optimizer phase we have:

<L29>:;
  fortran_character_1[1]{lb: 1 sz: 1} =
VIEW_CONVERT_EXPR<interfaces__fortran__character_set[1:1]>(*SR.237)[1]{lb: 1 
sz: 1};
  tc_fortran_character_1.26 = (const <unnamed type> *) &tc_fortran_character_1;
  D.2019 = *tc_fortran_character_1.26;

<bb 56>:
  D.2020 = (integer) D.2019;
  fortran_character_1.27 = (interfaces__fortran__character_set[1:1] *)
&fortran_character_1;
  D.2023 = *(const <unnamed type> *) fortran_character_1.27;

<bb 57>:
  if (D.2020 - (integer) D.2023 != 0) goto <L30>; else goto <L31>;

<L30>:;
  D.2026 = C.29;
  report__failed (D.2026);


which gets expanded into RTL like so:

(insn 497 496 499 73 (set (mem/s/j:QI (reg/f:SI 39 virtual-stack-vars) [11
fortran_character_1+0 S1 A64])
        (mem/s/j:QI (reg/f:SI 123 [ SR.237 ]) [11 S1 A8])) -1 (nil)
    (nil))

[snip]

(insn 503 502 504 74 (set (reg:SI 268 [ fortran_character_1.27 ])
        (reg/f:SI 39 virtual-stack-vars)) -1 (nil)
    (nil))

(insn 504 503 505 74 (set (reg:QI 267 [ D.2023 ])
        (mem:QI (reg:SI 268 [ fortran_character_1.27 ]) [28 S1 A8])) -1 (nil)
    (expr_list:REG_EH_REGION (const_int 2 [0x2])
        (nil)))

Notice how the store to fortran_character uses alias set 11,
while the read (via the fortran_character_1.27 pointer) uses
alias set 28.

The whole section gets further simplified to

(insn 1955 506 1956 56 (parallel [
            (set (mem/s/j:BLK (plus:SI (reg/f:SI 15 %r15)
                        (const_int 96 [0x60])) [11 fortran_character_1+0 S1 
A64])
                (mem/s/j:BLK (reg/f:SI 4 %r4 [orig:123 SR.237 ] [123]) [11 S1 
A8]))
            (use (const_int 1 [0x1]))
        ]) 61 {*mvc} (nil)
    (expr_list:REG_DEAD (reg/f:SI 4 %r4 [orig:123 SR.237 ] [123])
        (nil)))

(insn 1956 1955 508 56 (parallel [
            (set (reg:CCZ 33 %cc)
                (compare:CCZ (mem:BLK (plus:SI (reg/f:SI 15 %r15)
                            (const_int 96 [0x60])) [28 S1 A8])
                    (mem:BLK (plus:SI (reg/f:SI 15 %r15)
                            (const_int 97 [0x61])) [28 S1 A8])))
            (use (const_int 1 [0x1]))
        ]) 31 {*clc} (nil)
    (nil))

I.e. first the store to fortran_character, the the compare.
The scheduler now swaps the two insns, causing incorrect code
to be generated.  It hasn't recognized the dependency, presumably
because the alias sets are incorrect ...

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19382

Reply via email to