Floating/Double issue on arm64 in mob

Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Floating/Double issue on arm64 in mob

Charles Lohr
Using default settings, in hash 96f1fb1, current mob head, I am having an internal compiler assert on arm64.  The following program causes an assert.  There are other cases but the assert remains the same.

float fd;
int main()
{
        if( fd < 5.5 ) return 1;
        return 0;
}

root@omitted:~/apps/cnovr/lib/tinycc# ./tcc failtest.c  -Iinclude
tcc: arm64-gen.c:1781: gen_cvt_ftof: Assertion `f == VT_FLOAT || f == VT_DOUBLE || f == VT_LDOUBLE' failed.
Aborted

Digging a little further, turns out f is of type 4104.  I'm not sure what the best path forward here is.  Any clues?

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Floating/Double issue on arm64 in mob

Christian Jullien-3

I confirm this BUG which appends on my FC31 Rpi aarch64.

 

I “think” 4104 can be interpreted as VT_EXTERN | VT_FLOAT (i.e 0x00001000 | 0x8)

 

Quickly trying following diff looks to fix this issue (and makes the whole test suite still happy). I let maintainers tell me if it is the right fix to apply.

 

diff --git a/arm64-gen.c b/arm64-gen.c

index 5606271..5cd9e6b 100644

--- a/arm64-gen.c

+++ b/arm64-gen.c

@@ -1775,7 +1775,8 @@ ST_FUNC void gen_cvt_ftoi(int t)

 

ST_FUNC void gen_cvt_ftof(int t)

{

-    int f = vtop[0].type.t;

+    int f = vtop[0].type.t & VT_BTYPE;

+

     assert(t == VT_FLOAT || t == VT_DOUBLE || t == VT_LDOUBLE);

     assert(f == VT_FLOAT || f == VT_DOUBLE || f == VT_LDOUBLE);

     if (t == f)

 

 

From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Charles Lohr
Sent: Tuesday, November 05, 2019 07:52
To: [hidden email]
Subject: [Tinycc-devel] Floating/Double issue on arm64 in mob

 

Using default settings, in hash 96f1fb1, current mob head, I am having an internal compiler assert on arm64.  The following program causes an assert.  There are other cases but the assert remains the same.

 

float fd;
int main()
{
        if( fd < 5.5 ) return 1;
        return 0;
}

 

root@omitted:~/apps/cnovr/lib/tinycc# ./tcc failtest.c  -Iinclude
tcc: arm64-gen.c:1781: gen_cvt_ftof: Assertion `f == VT_FLOAT || f == VT_DOUBLE || f == VT_LDOUBLE' failed.
Aborted

 

Digging a little further, turns out f is of type 4104.  I'm not sure what the best path forward here is.  Any clues?


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Floating/Double issue on arm64 in mob

Shachaf Ben-Kiki
In reply to this post by Charles Lohr
On Mon, Nov 4, 2019 at 10:52 PM Charles Lohr <[hidden email]> wrote:

>
> Using default settings, in hash 96f1fb1, current mob head, I am having an internal compiler assert on arm64.  The following program causes an assert.  There are other cases but the assert remains the same.
>
> float fd;
> int main()
> {
>         if( fd < 5.5 ) return 1;
>         return 0;
> }
>
> root@omitted:~/apps/cnovr/lib/tinycc# ./tcc failtest.c  -Iinclude
> tcc: arm64-gen.c:1781: gen_cvt_ftof: Assertion `f == VT_FLOAT || f == VT_DOUBLE || f == VT_LDOUBLE' failed.
> Aborted
>
> Digging a little further, turns out f is of type 4104.  I'm not sure what the best path forward here is.  Any clues?
> _______________________________________________
> Tinycc-devel mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel

4104 is 0x1008, i.e. VT_FLOAT|VT_EXTERN. It looks like most of the
other backends mask VT_BTYPE (the basic type, without storage
modifiers) from t and vtop[0].type.t, so that would probably be the
simplest fix here.

(What's the process for sending patches?)

    Shachaf

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Floating/Double issue on arm64 in mob

Christian Jullien-3
In reply to this post by Charles Lohr

I added a test case in 22_floating_point.c and pushed the suggested fix in mod.

 

Christian

 

From: Christian Jullien [mailto:[hidden email]]
Sent: Tuesday, November 05, 2019 08:14
To: '[hidden email]'
Subject: RE: [Tinycc-devel] Floating/Double issue on arm64 in mob

 

I confirm this BUG which appends on my FC31 Rpi aarch64.

 

I “think” 4104 can be interpreted as VT_EXTERN | VT_FLOAT (i.e 0x00001000 | 0x8)

 

Quickly trying following diff looks to fix this issue (and makes the whole test suite still happy). I let maintainers tell me if it is the right fix to apply.

 

diff --git a/arm64-gen.c b/arm64-gen.c

index 5606271..5cd9e6b 100644

--- a/arm64-gen.c

+++ b/arm64-gen.c

@@ -1775,7 +1775,8 @@ ST_FUNC void gen_cvt_ftoi(int t)

 

ST_FUNC void gen_cvt_ftof(int t)

{

-    int f = vtop[0].type.t;

+    int f = vtop[0].type.t & VT_BTYPE;

+

     assert(t == VT_FLOAT || t == VT_DOUBLE || t == VT_LDOUBLE);

     assert(f == VT_FLOAT || f == VT_DOUBLE || f == VT_LDOUBLE);

     if (t == f)

 

 

From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Charles Lohr
Sent: Tuesday, November 05, 2019 07:52
To: [hidden email]
Subject: [Tinycc-devel] Floating/Double issue on arm64 in mob

 

Using default settings, in hash 96f1fb1, current mob head, I am having an internal compiler assert on arm64.  The following program causes an assert.  There are other cases but the assert remains the same.

 

float fd;
int main()
{
        if( fd < 5.5 ) return 1;
        return 0;
}

 

root@omitted:~/apps/cnovr/lib/tinycc# ./tcc failtest.c  -Iinclude
tcc: arm64-gen.c:1781: gen_cvt_ftof: Assertion `f == VT_FLOAT || f == VT_DOUBLE || f == VT_LDOUBLE' failed.
Aborted

 

Digging a little further, turns out f is of type 4104.  I'm not sure what the best path forward here is.  Any clues?


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Floating/Double issue on arm64 in mob

Charles Lohr
Thank youuuu!!!  This is some great stuff.  It's getting so rare I run into compiler bugs with TinyCC now.

On Fri, Nov 8, 2019 at 1:59 AM Christian Jullien <[hidden email]> wrote:

I added a test case in 22_floating_point.c and pushed the suggested fix in mod.

 

Christian

 

From: Christian Jullien [mailto:[hidden email]]
Sent: Tuesday, November 05, 2019 08:14
To: '[hidden email]'
Subject: RE: [Tinycc-devel] Floating/Double issue on arm64 in mob

 

I confirm this BUG which appends on my FC31 Rpi aarch64.

 

I “think” 4104 can be interpreted as VT_EXTERN | VT_FLOAT (i.e 0x00001000 | 0x8)

 

Quickly trying following diff looks to fix this issue (and makes the whole test suite still happy). I let maintainers tell me if it is the right fix to apply.

 

diff --git a/arm64-gen.c b/arm64-gen.c

index 5606271..5cd9e6b 100644

--- a/arm64-gen.c

+++ b/arm64-gen.c

@@ -1775,7 +1775,8 @@ ST_FUNC void gen_cvt_ftoi(int t)

 

ST_FUNC void gen_cvt_ftof(int t)

{

-    int f = vtop[0].type.t;

+    int f = vtop[0].type.t & VT_BTYPE;

+

     assert(t == VT_FLOAT || t == VT_DOUBLE || t == VT_LDOUBLE);

     assert(f == VT_FLOAT || f == VT_DOUBLE || f == VT_LDOUBLE);

     if (t == f)

 

 

From: Tinycc-devel [mailto:[hidden email]=[hidden email]] On Behalf Of Charles Lohr
Sent: Tuesday, November 05, 2019 07:52
To: [hidden email]
Subject: [Tinycc-devel] Floating/Double issue on arm64 in mob

 

Using default settings, in hash 96f1fb1, current mob head, I am having an internal compiler assert on arm64.  The following program causes an assert.  There are other cases but the assert remains the same.

 

float fd;
int main()
{
        if( fd < 5.5 ) return 1;
        return 0;
}

 

root@omitted:~/apps/cnovr/lib/tinycc# ./tcc failtest.c  -Iinclude
tcc: arm64-gen.c:1781: gen_cvt_ftof: Assertion `f == VT_FLOAT || f == VT_DOUBLE || f == VT_LDOUBLE' failed.
Aborted

 

Digging a little further, turns out f is of type 4104.  I'm not sure what the best path forward here is.  Any clues?

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel