The tranform would be unsafe if !TRULY_NOOP_TRUNCATION because on these
machines the hardware may look at bits outside of the given mode.
gcc/ChangeLog:
PR rtl-optimization/120050
* ext-dce.cc (ext_dce_try_optimize_insn): Only transform the
insn if TRULY_NOOP_TRUNCATION.
---
Bootstrapped on mips64el-linux-gnuabi64. Ok for trunk and gcc-15?
gcc/ext-dce.cc | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/gcc/ext-dce.cc b/gcc/ext-dce.cc
index a0343950141..4be4f8a007b 100644
--- a/gcc/ext-dce.cc
+++ b/gcc/ext-dce.cc
@@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see
#include "print-rtl.h"
#include "dbgcnt.h"
#include "diagnostic-core.h"
+#include "target.h"
/* These should probably move into a C++ class. */
static vec<bitmap_head> livein;
@@ -415,6 +416,13 @@ ext_dce_try_optimize_insn (rtx_insn *insn, rtx set)
return;
}
+ if (!TRULY_NOOP_TRUNCATION_MODES_P (GET_MODE (inner), GET_MODE (src)))
+ {
+ if (dump_file)
+ fprintf (dump_file, "The transformation is unsafe on this machine.\n");
+ return;
+ }
+
new_pattern = simplify_gen_subreg (GET_MODE (src), inner,
GET_MODE (inner), 0);
/* simplify_gen_subreg may fail in which case NEW_PATTERN will be NULL.
--
2.49.0