Fixed point and floating point comparision

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Fixed point and floating point comparision

Hubert Tong via cfe-dev
Hello,
When a comparison is made between the fixed point and floating point, the result is unspecified. Reference N1169 4.1.4 (Type conversion, usual arithmetic conversions).

In code, for fixed-point number, handleFixedPointConversion()(SemaExpr.cpp) is called,  I need to return unspecified.

   handleFixedPointConversion()  {
    if ((LHS is fixed point && RHS is floating point)  OR (RHS is fixed point && LHS is floating point)  )
      return unspecified.
    }


please let me know If anyone has idea, how to return unspecified or handle an unspecified case in UsualArithmeticConversions.

Regards,
Nadaf.

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Fixed point and floating point comparision

Hubert Tong via cfe-dev
Hi Gousemoodhin,

I don't think 4.1.4 mentions anything about comparisons. The only mention of unspecified with floating point is "The rounding of conversions from a fixed-point type to a floating point type is unspecified."

UsualArithmeticConversions and handleFixedPointConversion do not actually convert anything, they simply determine what the result type of the operation would be. So that would not be the place to 'determine' unspecified-ness; that would be a property of how the computation is performed in CodeGen or constant evaluation.

I'm assuming you are trying to implement the floating point portions of N1169. A lot of the necessary boilerplate is not in place for that, as I haven't had time to look at it much quite yet.

/ Bevin


From: cfe-dev <[hidden email]> on behalf of Gousemoodhin Nadaf via cfe-dev <[hidden email]>
Sent: Saturday, June 13, 2020 6:22 AM
To: [hidden email] <[hidden email]>
Subject: [cfe-dev] Fixed point and floating point comparision
 
Hello,
When a comparison is made between the fixed point and floating point, the result is unspecified. Reference N1169 4.1.4 (Type conversion, usual arithmetic conversions).

In code, for fixed-point number, handleFixedPointConversion()(SemaExpr.cpp) is called,  I need to return unspecified.

   handleFixedPointConversion()  {
    if ((LHS is fixed point && RHS is floating point)  OR (RHS is fixed point && LHS is floating point)  )
      return unspecified.
    }


please let me know If anyone has idea, how to return unspecified or handle an unspecified case in UsualArithmeticConversions.

Regards,
Nadaf.

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Fixed point and floating point comparision

Hubert Tong via cfe-dev
Hello Bevin,
As per N1169 4.1.4 (Type conversion, usual arithmetic conversions), conversions between the fixed point and floating point is unspecified. I believe before looking/checking for conversions, we have to handle unsupported conversions, if the conversion is not possible, we have to return NULL.

Let me know your opinions. 

Second patch updated: Changed word from "Comparision" to "Conversion", "Conversion" is correct word to describe. This verified on the local build, it does not lead to a compiler crash.

Regards,
Nadaf.  

On Tue, Jun 16, 2020 at 5:17 AM Bevin Hansson <[hidden email]> wrote:
Hi Gousemoodhin,

I don't think 4.1.4 mentions anything about comparisons. The only mention of unspecified with floating point is "The rounding of conversions from a fixed-point type to a floating point type is unspecified."

UsualArithmeticConversions and handleFixedPointConversion do not actually convert anything, they simply determine what the result type of the operation would be. So that would not be the place to 'determine' unspecified-ness; that would be a property of how the computation is performed in CodeGen or constant evaluation.

I'm assuming you are trying to implement the floating point portions of N1169. A lot of the necessary boilerplate is not in place for that, as I haven't had time to look at it much quite yet.

/ Bevin


From: cfe-dev <[hidden email]> on behalf of Gousemoodhin Nadaf via cfe-dev <[hidden email]>
Sent: Saturday, June 13, 2020 6:22 AM
To: [hidden email] <[hidden email]>
Subject: [cfe-dev] Fixed point and floating point comparision
 
Hello,
When a comparison is made between the fixed point and floating point, the result is unspecified. Reference N1169 4.1.4 (Type conversion, usual arithmetic conversions).

In code, for fixed-point number, handleFixedPointConversion()(SemaExpr.cpp) is called,  I need to return unspecified.

   handleFixedPointConversion()  {
    if ((LHS is fixed point && RHS is floating point)  OR (RHS is fixed point && LHS is floating point)  )
      return unspecified.
    }


please let me know If anyone has idea, how to return unspecified or handle an unspecified case in UsualArithmeticConversions.

Regards,
Nadaf.

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Fixed point and floating point comparision

Hubert Tong via cfe-dev

Hi,

 

I’m afraid I don’t agree with your interpretation. The spec says “The rounding of conversions […] is unspecified”, not that the conversions themselves are.

 

Floating-to-fixed point conversions just aren’t implemented yet, which is why it crashes. The support is still a bit experimental. I agree that it should not crash, though.

 

I will leave some comments in the patch.

 

/ Bevin

 

From: Gousemoodhin Nadaf <[hidden email]>
Sent: July 05, 2020 9:35 PM
To: Bevin Hansson <[hidden email]>
Cc: [hidden email]
Subject: Re: [cfe-dev] Fixed point and floating point comparision

 

Hello Bevin,
As per N1169 4.1.4 (Type conversion, usual arithmetic conversions), conversions between the fixed point and floating point is unspecified. I believe before looking/checking for conversions, we have to handle unsupported conversions, if the conversion is not possible, we have to return NULL.

Let me know your opinions. 

Second patch updated: Changed word from "Comparision" to "Conversion", "Conversion" is correct word to describe. This verified on the local build, it does not lead to a compiler crash.

Regards,
Nadaf.  

 

On Tue, Jun 16, 2020 at 5:17 AM Bevin Hansson <[hidden email]> wrote:

Hi Gousemoodhin,

 

I don't think 4.1.4 mentions anything about comparisons. The only mention of unspecified with floating point is "The rounding of conversions from a fixed-point type to a floating point type is unspecified."

 

UsualArithmeticConversions and handleFixedPointConversion do not actually convert anything, they simply determine what the result type of the operation would be. So that would not be the place to 'determine' unspecified-ness; that would be a property of how the computation is performed in CodeGen or constant evaluation.

 

I'm assuming you are trying to implement the floating point portions of N1169. A lot of the necessary boilerplate is not in place for that, as I haven't had time to look at it much quite yet.

 

/ Bevin

 


From: cfe-dev <[hidden email]> on behalf of Gousemoodhin Nadaf via cfe-dev <[hidden email]>
Sent: Saturday, June 13, 2020 6:22 AM
To: [hidden email] <[hidden email]>
Subject: [cfe-dev] Fixed point and floating point comparision

 

Hello,
When a comparison is made between the fixed point and floating point, the result is unspecified. Reference N1169 4.1.4 (Type conversion, usual arithmetic conversions).

In code, for fixed-point number, handleFixedPointConversion()(SemaExpr.cpp) is called,  I need to return unspecified.

   handleFixedPointConversion()  {
    if ((LHS is fixed point && RHS is floating point)  OR (RHS is fixed point && LHS is floating point)  )
      return unspecified.
    }


please let me know If anyone has idea, how to return unspecified or handle an unspecified case in UsualArithmeticConversions.

Regards,
Nadaf.


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Fixed point and floating point comparision

Hubert Tong via cfe-dev
Hello Bevin,
Thanks for inputs,
Update: As per N1169 4.1.4 (Type conversion, usual arithmetic conversions)

 If one of the operands has a floating type and the other operand has a fixed-point type, the fixedpoint operand is converted to the floating type in the usual way  

I will implement this logic (conversion from a fixed point to floating type), and will update further changes,

Regards,
Nadaf.

On Mon, Jul 6, 2020 at 4:36 AM Bevin Hansson <[hidden email]> wrote:

Hi,

 

I’m afraid I don’t agree with your interpretation. The spec says “The rounding of conversions […] is unspecified”, not that the conversions themselves are.

 

Floating-to-fixed point conversions just aren’t implemented yet, which is why it crashes. The support is still a bit experimental. I agree that it should not crash, though.

 

I will leave some comments in the patch.

 

/ Bevin

 

From: Gousemoodhin Nadaf <[hidden email]>
Sent: July 05, 2020 9:35 PM
To: Bevin Hansson <[hidden email]>
Cc: [hidden email]
Subject: Re: [cfe-dev] Fixed point and floating point comparision

 

Hello Bevin,
As per N1169 4.1.4 (Type conversion, usual arithmetic conversions), conversions between the fixed point and floating point is unspecified. I believe before looking/checking for conversions, we have to handle unsupported conversions, if the conversion is not possible, we have to return NULL.

Let me know your opinions. 

Second patch updated: Changed word from "Comparision" to "Conversion", "Conversion" is correct word to describe. This verified on the local build, it does not lead to a compiler crash.

Regards,
Nadaf.  

 

On Tue, Jun 16, 2020 at 5:17 AM Bevin Hansson <[hidden email]> wrote:

Hi Gousemoodhin,

 

I don't think 4.1.4 mentions anything about comparisons. The only mention of unspecified with floating point is "The rounding of conversions from a fixed-point type to a floating point type is unspecified."

 

UsualArithmeticConversions and handleFixedPointConversion do not actually convert anything, they simply determine what the result type of the operation would be. So that would not be the place to 'determine' unspecified-ness; that would be a property of how the computation is performed in CodeGen or constant evaluation.

 

I'm assuming you are trying to implement the floating point portions of N1169. A lot of the necessary boilerplate is not in place for that, as I haven't had time to look at it much quite yet.

 

/ Bevin

 


From: cfe-dev <[hidden email]> on behalf of Gousemoodhin Nadaf via cfe-dev <[hidden email]>
Sent: Saturday, June 13, 2020 6:22 AM
To: [hidden email] <[hidden email]>
Subject: [cfe-dev] Fixed point and floating point comparision

 

Hello,
When a comparison is made between the fixed point and floating point, the result is unspecified. Reference N1169 4.1.4 (Type conversion, usual arithmetic conversions).

In code, for fixed-point number, handleFixedPointConversion()(SemaExpr.cpp) is called,  I need to return unspecified.

   handleFixedPointConversion()  {
    if ((LHS is fixed point && RHS is floating point)  OR (RHS is fixed point && LHS is floating point)  )
      return unspecified.
    }


please let me know If anyone has idea, how to return unspecified or handle an unspecified case in UsualArithmeticConversions.

Regards,
Nadaf.


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Fixed point and floating point comparision

Hubert Tong via cfe-dev
Hello Team,
Reworked on comments, please review  https://reviews.llvm.org/D81904

Regards,
Nadaf.

On Wed, Jul 8, 2020 at 2:50 PM Gousemoodhin Nadaf <[hidden email]> wrote:
Hello Bevin,
Thanks for inputs,
Update: As per N1169 4.1.4 (Type conversion, usual arithmetic conversions)

 If one of the operands has a floating type and the other operand has a fixed-point type, the fixedpoint operand is converted to the floating type in the usual way  

I will implement this logic (conversion from a fixed point to floating type), and will update further changes,

Regards,
Nadaf.

On Mon, Jul 6, 2020 at 4:36 AM Bevin Hansson <[hidden email]> wrote:

Hi,

 

I’m afraid I don’t agree with your interpretation. The spec says “The rounding of conversions […] is unspecified”, not that the conversions themselves are.

 

Floating-to-fixed point conversions just aren’t implemented yet, which is why it crashes. The support is still a bit experimental. I agree that it should not crash, though.

 

I will leave some comments in the patch.

 

/ Bevin

 

From: Gousemoodhin Nadaf <[hidden email]>
Sent: July 05, 2020 9:35 PM
To: Bevin Hansson <[hidden email]>
Cc: [hidden email]
Subject: Re: [cfe-dev] Fixed point and floating point comparision

 

Hello Bevin,
As per N1169 4.1.4 (Type conversion, usual arithmetic conversions), conversions between the fixed point and floating point is unspecified. I believe before looking/checking for conversions, we have to handle unsupported conversions, if the conversion is not possible, we have to return NULL.

Let me know your opinions. 

Second patch updated: Changed word from "Comparision" to "Conversion", "Conversion" is correct word to describe. This verified on the local build, it does not lead to a compiler crash.

Regards,
Nadaf.  

 

On Tue, Jun 16, 2020 at 5:17 AM Bevin Hansson <[hidden email]> wrote:

Hi Gousemoodhin,

 

I don't think 4.1.4 mentions anything about comparisons. The only mention of unspecified with floating point is "The rounding of conversions from a fixed-point type to a floating point type is unspecified."

 

UsualArithmeticConversions and handleFixedPointConversion do not actually convert anything, they simply determine what the result type of the operation would be. So that would not be the place to 'determine' unspecified-ness; that would be a property of how the computation is performed in CodeGen or constant evaluation.

 

I'm assuming you are trying to implement the floating point portions of N1169. A lot of the necessary boilerplate is not in place for that, as I haven't had time to look at it much quite yet.

 

/ Bevin

 


From: cfe-dev <[hidden email]> on behalf of Gousemoodhin Nadaf via cfe-dev <[hidden email]>
Sent: Saturday, June 13, 2020 6:22 AM
To: [hidden email] <[hidden email]>
Subject: [cfe-dev] Fixed point and floating point comparision

 

Hello,
When a comparison is made between the fixed point and floating point, the result is unspecified. Reference N1169 4.1.4 (Type conversion, usual arithmetic conversions).

In code, for fixed-point number, handleFixedPointConversion()(SemaExpr.cpp) is called,  I need to return unspecified.

   handleFixedPointConversion()  {
    if ((LHS is fixed point && RHS is floating point)  OR (RHS is fixed point && LHS is floating point)  )
      return unspecified.
    }


please let me know If anyone has idea, how to return unspecified or handle an unspecified case in UsualArithmeticConversions.

Regards,
Nadaf.


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev