===================================================================
@@ -240,6 +240,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree-pass.h"
#include "df.h"
#include "cgraph.h"
+#include "insn-attr.h"
/* This structure represents a candidate for elimination. */
@@ -756,6 +757,41 @@ combine_reaching_defs (ext_cand *cand, const_rtx s
return false;
}
+/* Given an INSN, obtain the attr_mode specified by the machine
+ model, and map it to the corresponding machine_mode. If the
+ attr_mode isn't available, return the machine mode for DEST. */
+
+static enum machine_mode
+get_mode (rtx insn, rtx dest)
+{
+ enum machine_mode mode;
+
+#ifdef HAVE_ATTR_mode
+ switch (get_attr_mode (insn))
+ {
+ case MODE_QI:
+ mode = QImode;
+ break;
+ case MODE_HI:
+ mode = HImode;
+ break;
+ case MODE_SI:
+ mode = SImode;
+ break;
+ case MODE_DI:
+ mode = DImode;
+ break;
+ default:
+ mode = GET_MODE (dest);
+ break;
+ }
+#else
+ mode = GET_MODE (dest);
+#endif
+
+ return mode;
+}
+
/* Add an extension pattern that could be eliminated. */
static void
@@ -775,7 +811,7 @@ add_removable_extension (const_rtx expr, rtx insn,
src = SET_SRC (expr);
code = GET_CODE (src);
dest = SET_DEST (expr);
- mode = GET_MODE (dest);
+ mode = get_mode (insn, dest);
if (REG_P (dest)
&& (code == SIGN_EXTEND || code == ZERO_EXTEND)