This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] tree-sra: fix compare_access_positions qsort comparator


On Thu, 21 Sep 2017, Richard Sandiford wrote:
> LGTM FWIW, but isn't there also the problem that the TYPE_PRECISION
> test fails to stabilise the sort if you have two integral types with
> the same precision?

Yes, but that's a pre-existing issue, so I didn't change it in the patch.
I think GCC broadly makes an assumption that libc qsort is deterministic,
i.e. as long as comparators are deterministic, outcome of qsort doesn't
change across compiler runs.  In this case qsort behaviour affects IR on
a testcase like this:

long g()
{
  struct s {union { unsigned long ul; long l;}; } s;
  asm("# %0" : "=X"(s.ul));
  return s.l;
}

(sort order determines types of post-early-SRA temporaries), so I guess
it's desirable to stabilize it.

Is this patch OK as is, or do I need to resubmit a variant that uses
TYPE_UID comparison in case TYPE_PRECISION is equal?

Thanks.
Alexander


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]