Bug 68832 - FAIL: gcc.c-torture/execute/alias-2.c -O1 execution test
Summary: FAIL: gcc.c-torture/execute/alias-2.c -O1 execution test
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
: 69206 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-12-10 11:17 UTC by Andreas Schwab
Modified: 2016-01-19 12:45 UTC (History)
2 users (show)

See Also:
Host:
Target: aarch64-*-*, arm*-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-12-10 00:00:00


Attachments
proposed fix (1.42 KB, patch)
2015-12-16 20:52 UTC, Jan Hubicka
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Schwab 2015-12-10 11:17:02 UTC
$ gcc/xgcc -Bgcc/ ../../gcc/gcc/testsuite/gcc.c-torture/execute/alias-2.c -O1 -lm -o ./alias-2.exe
../../gcc/gcc/testsuite/gcc.c-torture/execute/alias-2.c:5:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
 main()
 ^~~~

$ ./alias-2.exe
Aborted (core dumped)

abort is called unconditionally, the condition disappears during fwprop1.
Comment 1 Richard Biener 2015-12-10 11:36:08 UTC
I think a commit-order mixup?  Works for me on x86_64.  fwprop1 doesn't make
much sense to me...
Comment 2 ktkachov 2015-12-10 13:49:45 UTC
I see this on aarch64 as well.
For me the abort becomes unconditional with cse1
Comment 3 ktkachov 2015-12-10 14:00:49 UTC
Fails on arm too
Comment 4 Richard Biener 2015-12-11 08:39:22 UTC
Honza, please have a look here.
Comment 5 Jan Hubicka 2015-12-16 19:25:12 UTC
I will take a look. Seems something still needs update for alias.
Comment 6 Jan Hubicka 2015-12-16 20:04:38 UTC
The bug is caused by achors.  We call

Breakpoint 6, write_dependence_p (mem=0x7ffff69006f0, x=0x7ffff69006c0, x_mode=SImode, x_addr=0x7ffff6900690, mem_canonicalized=true, x_canonicalized=true, writep=false)
    at ../../gcc/alias.c:2897
2897      gcc_checking_assert (x_canonicalized
(gdb) p debug_rtx (x)
(mem:SI (plus:SI (mult:SI (reg:SI 110 [ off.0_2 ])
            (const_int 4 [0x4]))
        (symbol_ref:SI ("*.LANCHOR0") [flags 0x182])) [1 a S4 A32])
$38 = void
(gdb) p debug_rtx (mem)
(mem:SI (plus:SI (mult:SI (reg:SI 110 [ off.0_2 ])
            (const_int 4 [0x4]))
        (symbol_ref:SI ("b") [flags 0x2]  <var_decl 0x7ffff7ff8a20 b>)) [1 b S4 A32])
$39 = void

which is OK but we also have:
(gdb) p debug_rtx (x_addr)
(plus:SI (mult:SI (reg:SI 110 [ off.0_2 ])
        (const_int 4 [0x4]))
    (symbol_ref:SI ("*.LANCHOR0") [flags 0x182]))
$50 = void

and we dispatch to:
Breakpoint 9, base_alias_check (x=0x7ffff6900690, x_base=0x7ffff68fb5f0, y=0x7ffff69006d8, y_base=0x7ffff68fef48, x_mode=SImode, y_mode=SImode) at ../../gcc/alias.c:2065
(gdb) p debug_rtx (x_base)
(symbol_ref:SI ("*.LANCHOR0") [flags 0x182])
$57 = void
(gdb) p debug_rtx (y_base)
(symbol_ref:SI ("b") [flags 0x2]  <var_decl 0x7ffff7ff8a20 b>)
$58 = void

and eventually we return 0 in:
  if (GET_CODE (x_base) == SYMBOL_REF && GET_CODE (y_base) == SYMBOL_REF)
    {
      tree x_decl = SYMBOL_REF_DECL (x_base);
      tree y_decl = SYMBOL_REF_DECL (y_base);

      /* We can assume that no stores are made to labels.  */
      if (!x_decl || !y_decl)
        return 0;
      return compare_base_decls (x_decl, y_decl) != 0;
    }

because x_base is NULL.  I suppose easy fix is to always return true for anchor/decl compare, but perhaps there is a better way to check if the anchor possibly corresponds to the declaration?
Comment 7 Jan Hubicka 2015-12-16 20:52:39 UTC
Created attachment 37055 [details]
proposed fix

This patch adds compare of anchored variables
Comment 8 Andrew Pinski 2016-01-09 10:59:23 UTC
*** Bug 69206 has been marked as a duplicate of this bug. ***
Comment 9 Jan Hubicka 2016-01-19 12:45:29 UTC
Should be fixed by the following commit:
2016-01-14  Jan Hubicka  <hubicka@ucw.cz>                                       
                                                                                
        * alias.c (compare_base_symbol_refs): New function.                     
        (rtx_equal_for_memref_p, base_alias_check, memrefs_conflict_p): Use     
        it.