Bug 29864

Summary: Folding conversion unsigned long long to float
Product: gcc Reporter: Erwin Unruh <Erwin.Unruh>
Component: middle-endAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs
Priority: P3 Keywords: wrong-code
Version: 4.3.0   
Target Milestone: 4.4.0   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2006-11-16 09:54:40

Description Erwin Unruh 2006-11-16 08:19:26 UTC
In Funktion expand_float the libcall generated for a conversion from unsigned long long to float gets a wrong EQUIV note. See line optabs.c:4712 in the 4.3-20061111 snapshot. The equiv note is set to gen_rtx_FLOAT regardless of the unsignedp flag. When that flag is set, it should be a gen_rtx_UNSIGNED_FLOAT note.
The error is also present in 4.2. In 4.1 it was hidden because the code was only executed with unsignedp being false.
I found the problem while working on a private port. I do not have a confirmed testcase for a public port. The problem surfaced when GCSE eliminated the libcall using the note for the conversion.
Comment 1 Richard Biener 2006-11-16 09:54:40 UTC
Confirmed.
Comment 2 Richard Biener 2008-02-04 15:52:59 UTC
A testcase would probably be sth along the lines of

extern void abort (void);
void __attribute__((noinline)) foo (unsigned long long x)
{
  float uf = x;
  float sf = (signed long long)x;
  if (uf == sf)
    abort ();
}
int main()
{
  foo (-1);
  return 0;
}

with the right target and soft-float (any suggestion?).
Comment 3 Andrew Pinski 2021-08-08 21:35:41 UTC
Fixed at r0-87005.