]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end: Fix stalled swapped condition code value [PR115836]
authorUros Bizjak <ubizjak@gmail.com>
Wed, 10 Jul 2024 07:27:27 +0000 (09:27 +0200)
committerUros Bizjak <ubizjak@gmail.com>
Wed, 10 Jul 2024 19:53:41 +0000 (21:53 +0200)
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.c (emit_store_flag_1): Move calculation of
scode just before its only usage site.

(cherry picked from commit 44933fdeb338e00c972e42224b9a83d3f8f6a757)

gcc/expmed.c

index 3143f38e0570eabe56cf82c49fb84752d8e170f0..2c916eab43b6b76b06536352bcaa52ef42c11d05 100644 (file)
@@ -5589,11 +5589,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.  */
@@ -5761,6 +5759,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)