]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
AArch64: Improve costing of ctz
authorWilco Dijkstra <wilco.dijkstra@arm.com>
Wed, 17 Apr 2024 16:18:23 +0000 (17:18 +0100)
committerWilco Dijkstra <wilco.dijkstra@arm.com>
Mon, 20 May 2024 15:06:38 +0000 (16:06 +0100)
Improve costing of ctz - both TARGET_CSSC and vector cases were not handled yet.

gcc:
* config/aarch64/aarch64.cc (aarch64_rtx_costs): Improve CTZ costing.

gcc/config/aarch64/aarch64.cc

index 662ff5a9b0c715d0cab0ae4ba63af1b3c8ebbd00..ee12d8897a8836b105f4e337834947ad6cefdcb3 100644 (file)
@@ -14349,10 +14349,24 @@ aarch64_rtx_costs (rtx x, machine_mode mode, int outer ATTRIBUTE_UNUSED,
       return false;
 
     case CTZ:
-      *cost = COSTS_N_INSNS (2);
-
-      if (speed)
-       *cost += extra_cost->alu.clz + extra_cost->alu.rev;
+      if (VECTOR_MODE_P (mode))
+       {
+         *cost = COSTS_N_INSNS (3);
+         if (speed)
+           *cost += extra_cost->vect.alu * 3;
+       }
+      else if (TARGET_CSSC)
+       {
+         *cost = COSTS_N_INSNS (1);
+         if (speed)
+           *cost += extra_cost->alu.clz;
+       }
+      else
+       {
+         *cost = COSTS_N_INSNS (2);
+         if (speed)
+           *cost += extra_cost->alu.clz + extra_cost->alu.rev;
+       }
       return false;
 
     case COMPARE: