Bug 65170 - [5 Regression] curve25519-donna-c64 miscompilation
Summary: [5 Regression] curve25519-donna-c64 miscompilation
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 5.0
: P1 major
Target Milestone: 5.0
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-23 09:59 UTC by Sami Farin
Modified: 2015-02-24 08:21 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-02-23 00:00:00


Attachments
curve25519-donna-c64.c (3.59 KB, text/x-csrc)
2015-02-23 09:59 UTC, Sami Farin
Details
gcc5-pr65170.patch (992 bytes, patch)
2015-02-23 15:39 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sami Farin 2015-02-23 09:59:40 UTC
Created attachment 34841 [details]
curve25519-donna-c64.c

curve25519-donna-c64.c function curve25519_donna with gcc-5.0.0-0.15.fc22,
flag -O3 , sets mypublic to all-zeros.
If I remove force_inline from fmul(), it compiles ok.
Could not produce a smaller test case.
Comment 1 Jakub Jelinek 2015-02-23 12:19:19 UTC
Started with r220164.  So, either the VR info before vrp2 pass is already wrong, or something goes wrong during the vrp2 pass.  Note the testcase uses TImode heavily.
Comment 2 Jakub Jelinek 2015-02-23 13:11:56 UTC
I believe this boils down to
__attribute__((noinline, noclone)) void
foo (__uint128_t b, __uint128_t c)
{
  __uint128_t a;
  b &= -1ULL;
  c &= -1ULL;
  a = b * c;
  if (a != 1)
    __builtin_abort ();
}

int
main ()
{
  foo (1, 1);
  return 0;
}
which at -O2 regressed with r210113 aka the wide-int merge.  Will look at it.
Comment 3 Jakub Jelinek 2015-02-23 15:39:25 UTC
Created attachment 34844 [details]
gcc5-pr65170.patch

Untested fix.
Comment 4 Jakub Jelinek 2015-02-24 08:07:41 UTC
Author: jakub
Date: Tue Feb 24 08:07:10 2015
New Revision: 220931

URL: https://gcc.gnu.org/viewcvs?rev=220931&root=gcc&view=rev
Log:
	PR tree-optimization/65170
	* wide-int.cc (wi::mul_internal): For the umul_ppmm optimization,
	if val[1] < 0, clear also val[2] and return 3.

	* gcc.c-torture/execute/pr65170.c: New test.
	* gcc.dg/tree-ssa/vrp96.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr65170.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/vrp96.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/wide-int.cc
    trunk/libsanitizer/ChangeLog
Comment 5 Jakub Jelinek 2015-02-24 08:21:54 UTC
Fixed now.