[amdgcn] Add support for unordered floating-point comparisons

Message ID 3ffcef54-43a4-022f-de36-fd8a5e068bab@codesourcery.com
State New
Headers show
Series
  • [amdgcn] Add support for unordered floating-point comparisons
Related show

Commit Message

Kwok Cheung Yeung April 2, 2020, 2:55 p.m.
Hello

This patch adds support for the unordered floating-point comparison operators 
(UNEQ, UNGE, UNGT, UNLE, UNLT), which return true if one of the operands is a 
NaN. These comparisons can be generated by builtins such as __builtin_isgreater.

GCC 10 appears to have a fall-back if the unordered comparisons are not 
available (by generating an unordered comparison first, followed by the main 
comparison), whereas previous versions would simply throw an ICE. Still, it 
should be a little more efficient to have direct support for these operators.

Tested on a GCN3 board with no regressions noted. Okay for trunk?

Kwok
commit ea811ce38ae2127554f0aca9cd34aca6e42f814d
Author: Kwok Cheung Yeung <kcy@codesourcery.com>
Date:   Thu Apr 2 07:47:28 2020 -0700

    amdgcn: Support unordered floating-point comparison operators
    
    2020-04-02  Kwok Cheung Yeung  <kcy@codesourcery.com>
    
    	gcc/
    	* config/gcn/gcn.c (print_operand): Handle unordered comparison
    	operators.
    	* config/gcn/predicates.md (gcn_fp_compare_operator): Add unordered
    	comparison operators.

Comments

Andrew Stubbs April 2, 2020, 3:36 p.m. | #1
On 02/04/2020 15:55, Kwok Cheung Yeung wrote:
> Hello

> 

> This patch adds support for the unordered floating-point comparison 

> operators (UNEQ, UNGE, UNGT, UNLE, UNLT), which return true if one of 

> the operands is a NaN. These comparisons can be generated by builtins 

> such as __builtin_isgreater.

> 

> GCC 10 appears to have a fall-back if the unordered comparisons are not 

> available (by generating an unordered comparison first, followed by the 

> main comparison), whereas previous versions would simply throw an ICE. 

> Still, it should be a little more efficient to have direct support for 

> these operators.

> 

> Tested on a GCN3 board with no regressions noted. Okay for trunk?


OK, thanks.

Andrew

Patch

diff --git a/gcc/config/gcn/gcn.c b/gcc/config/gcn/gcn.c
index 12438cf..38b5b98 100644
--- a/gcc/config/gcn/gcn.c
+++ b/gcc/config/gcn/gcn.c
@@ -6007,6 +6007,21 @@  print_operand (FILE *file, rtx x, int code)
 	  case UNORDERED:
 	    s = "_u_";
 	    break;
+	  case UNEQ:
+	    s = "_nlg_";
+	    break;
+	  case UNGE:
+	    s = "_nlt_";
+	    break;
+	  case UNGT:
+	    s = "_nle_";
+	    break;
+	  case UNLE:
+	    s = "_ngt_";
+	    break;
+	  case UNLT:
+	    s = "_nge_";
+	    break;
 	  case LTGT:
 	    s = "_lg_";
 	    break;
diff --git a/gcc/config/gcn/predicates.md b/gcc/config/gcn/predicates.md
index 7bf763a..91e5ca1 100644
--- a/gcc/config/gcn/predicates.md
+++ b/gcc/config/gcn/predicates.md
@@ -165,7 +165,7 @@ 
   (match_code "eq,ne,gt,ge,lt,le,gtu,geu,ltu,leu"))
 
 (define_predicate "gcn_fp_compare_operator"
-  (match_code "eq,ne,gt,ge,lt,le,gtu,geu,ltu,leu,ordered,unordered,ltgt"))
+  (match_code "eq,ne,gt,ge,lt,le,gtu,geu,ltu,leu,ordered,unordered,uneq,unge,ungt,unle,unlt,ltgt"))
 
 (define_predicate "unary_operator"
   (match_code "not,popcount"))