diff mbox series

middle-end: Fix stalled swapped condition code value [PR115836]

Message ID CAFULd4YrrdfM1MWajs0N8Nr+kGjFt0mQVxXOihuFfwbPFn_ahQ@mail.gmail.com
State New
Headers show
Series middle-end: Fix stalled swapped condition code value [PR115836] | expand

Commit Message

Uros Bizjak July 10, 2024, 7:49 a.m. UTC
emit_store_flag_1 calculates scode (swapped condition code) at the
beginning of the function from the value of code variable.  However,
code variable may change before scode usage site, resulting in
invalid stalled scode value.

Move calculation of scode value just before its only usage site to
avoid stalled scode value.

    PR middle-end/115836

gcc/ChangeLog:

    * expmed.cc (emit_store_flag_1): Move calculation of
    scode just before its only usage site.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Also tested with original and minimized preprocessed source.
Unfortunately, even with the minimized source, the compilation takes
~5 minutes, and IMO such a trivial fix does not warrant that high
resource consumption.

OK for master and release branches?

Uros.

Comments

Richard Biener July 10, 2024, 8:33 a.m. UTC | #1
On Wed, 10 Jul 2024, Uros Bizjak wrote:

> emit_store_flag_1 calculates scode (swapped condition code) at the
> beginning of the function from the value of code variable.  However,
> code variable may change before scode usage site, resulting in
> invalid stalled scode value.
> 
> Move calculation of scode value just before its only usage site to
> avoid stalled scode value.
> 
>     PR middle-end/115836
> 
> gcc/ChangeLog:
> 
>     * expmed.cc (emit_store_flag_1): Move calculation of
>     scode just before its only usage site.
> 
> Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.
> 
> Also tested with original and minimized preprocessed source.
> Unfortunately, even with the minimized source, the compilation takes
> ~5 minutes, and IMO such a trivial fix does not warrant that high
> resource consumption.
> 
> OK for master and release branches?

OK.

Thanks,
Richard.
diff mbox series

Patch

diff --git a/gcc/expmed.cc b/gcc/expmed.cc
index 8bbbc94a98c..154964bd068 100644
--- a/gcc/expmed.cc
+++ b/gcc/expmed.cc
@@ -5632,11 +5632,9 @@  emit_store_flag_1 (rtx target, enum rtx_code code, rtx op0, rtx op1,
   enum insn_code icode;
   machine_mode compare_mode;
   enum mode_class mclass;
-  enum rtx_code scode;
 
   if (unsignedp)
     code = unsigned_condition (code);
-  scode = swap_condition (code);
 
   /* If one operand is constant, make it the second one.  Only do this
      if the other operand is not constant as well.  */
@@ -5751,6 +5749,8 @@  emit_store_flag_1 (rtx target, enum rtx_code code, rtx op0, rtx op1,
 
 	  if (GET_MODE_CLASS (mode) == MODE_FLOAT)
 	    {
+	      enum rtx_code scode = swap_condition (code);
+
 	      tem = emit_cstore (target, icode, scode, mode, compare_mode,
 				 unsignedp, op1, op0, normalizep, target_mode);
 	      if (tem)