public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/46399] New: Missing type promotion for library call argument
@ 2010-11-09 17:09 krebbel at gcc dot gnu.org
  2010-11-09 17:10 ` [Bug middle-end/46399] " krebbel at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: krebbel at gcc dot gnu.org @ 2010-11-09 17:09 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Missing type promotion for library call argument
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: krebbel@gcc.gnu.org


The following testcase produces an unexpected result when compiled with:
gcc -O3 t.c -ot

int
main ()
{
  volatile _Decimal32 b, c;
  volatile unsigned int ui;
  volatile long long sll;

  ui = 1;
  sll = 1LL;
  b = sll;
  c = ui;

  printf("b: %x\n", *(int*)&b);
  printf("c: %x\n", *(int*)&c);
}

./t:
b: 22500001
c: 3a95e225

The problem appears to be a missing type promotion when doing the conversion
from unsigned int to _Decimal32 in c = ui:

        stmg    %r14,%r15,112(%r15)
        aghi    %r15,-184
        lhi     %r1,1
        st      %r1,180(%r15)
        lghi    %r1,1
        stg     %r1,160(%r15)
        lg      %r2,160(%r15)           <-- load a 64bit value into r2
        brasl   %r14,__dpd_floatdisd
        ste     %f0,172(%r15)
        l       %r2,180(%r15)           <-- load a 32bit value into r2
        brasl   %r14,__dpd_floatunssisd     without zero extending to 64bit
        ....

When I manually kill the upper 32 bits of r2 before doing the second lib call
it works fine:

        stmg    %r14,%r15,112(%r15)
        aghi    %r15,-184
        .cfi_offset 15, -40
        .cfi_offset 14, -48
        .cfi_def_cfa_offset 344
        lhi     %r1,1
        st      %r1,180(%r15)
        lghi    %r1,1
        stg     %r1,160(%r15)
        lg      %r2,160(%r15)
        brasl   %r14,__dpd_floatdisd
        ste     %f0,172(%r15)
        lghi    %r2,0                    <-- load a 64bit 0 into r2
        l       %r2,180(%r15)
        brasl   %r14,__dpd_floatunssisd
        ...

The result then is:
b: 22500001
c: 22500001


The testcase above is extracted from gcc.dg/dfp/pr41049.c which currently seems
to fail due to that problem on s390*.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-07-31  7:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-09 17:09 [Bug middle-end/46399] New: Missing type promotion for library call argument krebbel at gcc dot gnu.org
2010-11-09 17:10 ` [Bug middle-end/46399] " krebbel at gcc dot gnu.org
2011-05-09  8:56 ` krebbel at gcc dot gnu.org
2011-05-09  9:24 ` krebbel at gcc dot gnu.org
2013-07-31  7:59 ` krebbel at gcc dot gnu.org
2013-07-31  7:59 ` krebbel at gcc dot gnu.org
2013-07-31  7:59 ` krebbel at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).