This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: fwprop changes to fix pr41081


On 08/22/2009 07:18 AM, Alan Modra wrote:
+#ifdef LOAD_EXTEND_OP
+static df_ref
+get_reg_use_in (rtx insn, rtx reg)
+{
+  df_ref *use_vec;
+
+  for (use_vec = DF_INSN_USES (insn); *use_vec; use_vec++)
+    {
+      df_ref use = *use_vec;
+
+      if (!DF_REF_IS_ARTIFICIAL (use)
+	&&  DF_REF_TYPE (use) == DF_REF_REG_USE
+	&&  DF_REF_REG (use) == reg)
+	return use;
+    }
+  return NULL;
+}
+#endif
...
+      if ((GET_CODE (src) == ZERO_EXTEND
+	   || GET_CODE (src) == SIGN_EXTEND)
+	&&  REG_P (XEXP (src, 0))
+	&&  GET_MODE (XEXP (src, 0)) == use_mode
+#ifdef LOAD_EXTEND_OP
+	&&  (LOAD_EXTEND_OP (use_mode) != GET_CODE (src)
+	      || (prev_use = get_reg_use_in (def_insn, XEXP (src, 0))) == NULL
+	      || (prev_def = get_def_for_use (prev_use)) == NULL
+	      || DF_REF_IS_ARTIFICIAL (prev_def)
+	      || !NONJUMP_INSN_P (DF_REF_INSN (prev_def))
+	      || GET_CODE (PATTERN (DF_REF_INSN (prev_def))) != SET
+	      || GET_CODE (SET_SRC (PATTERN (DF_REF_INSN (prev_def)))) != MEM
+	      || !rtx_equal_p (SET_DEST (PATTERN (DF_REF_INSN (prev_def))),
+			       XEXP (src, 0)))
+#endif
+	&&  all_uses_available_at (def_insn, use_insn))

I really don't like to see either ifdefs or assignments inside if conditions.

I think this would be better written like

   if (GET_CODE (src) == ...
       && avoid_bypass_free_load_extend (use_mode, src, other, args)
       && all_uses_available_at (...))

static bool
avoid_bypass_free_load_extend (args)
{
  enum rtx_code code = UNKNOWN;

#ifdef LOAD_EXTEND_OP
  code = LOAD_EXTEND_OP (use_mode);
#endif
  if (code != GET_CODE (src))
    return false;
  ...
}

Considering the size of your condition, I think this will
be greatly more readable.


r~



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]