]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
math-opts: Add dbgcounter for FMA formation
authorMartin Jambor <mjambor@suse.cz>
Tue, 12 Sep 2023 17:22:37 +0000 (19:22 +0200)
committerMartin Jambor <mjambor@suse.cz>
Tue, 12 Sep 2023 17:23:20 +0000 (19:23 +0200)
This patch is a simple addition of a debug counter to FMA formation in
tree-ssa-math-opts.cc.  Given that issues with FMAs do occasionally
pop up, it seems genuinely useful.

I simply added an if right after the initial checks in
convert_mult_to_fma even though when FMA formation deferring is
active (i.e. when targeting Zen CPUs) this would interact with it (and
at this moment lead to producing all deferred candidates), so when
using the dbg counter to find a harmful set of FMAs, it is probably
best to also set param_avoid_fma_max_bits to zero.  I could not find a
better place which would not also make the code unnecessarily more
complicated.

gcc/ChangeLog:

2023-09-06  Martin Jambor  <mjambor@suse.cz>

* dbgcnt.def (form_fma): New.
* tree-ssa-math-opts.cc: Include dbgcnt.h.
(convert_mult_to_fma): Bail out if the debug counter say so.

gcc/dbgcnt.def
gcc/tree-ssa-math-opts.cc

index 9e2f1d857b49c6c331cc7d1c419eafa0f2403e96..871cbf75d9317448d549e16aefa5f77a062cacdc 100644 (file)
@@ -162,6 +162,7 @@ DEBUG_COUNTER (dom_unreachable_edges)
 DEBUG_COUNTER (dse)
 DEBUG_COUNTER (dse1)
 DEBUG_COUNTER (dse2)
+DEBUG_COUNTER (form_fma)
 DEBUG_COUNTER (gcse2_delete)
 DEBUG_COUNTER (gimple_unroll)
 DEBUG_COUNTER (global_alloc_at_func)
index 95c22694368c8d67b420d9b713a126a28bf0f027..3db69ad5733cf86a197ad2f0a169f926e7b6b755 100644 (file)
@@ -116,6 +116,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "targhooks.h"
 #include "domwalk.h"
 #include "tree-ssa-math-opts.h"
+#include "dbgcnt.h"
 
 /* This structure represents one basic block that either computes a
    division, or is a common dominator for basic block that compute a
@@ -3366,6 +3367,9 @@ convert_mult_to_fma (gimple *mul_stmt, tree op1, tree op2,
       && !has_single_use (mul_result))
     return false;
 
+  if (!dbg_cnt (form_fma))
+    return false;
+
   /* Make sure that the multiplication statement becomes dead after
      the transformation, thus that all uses are transformed to FMAs.
      This means we assume that an FMA operation has the same cost