Just like CONST_INT, CONST_WIDE_INT is VOIDmode, so LRA might be
tempted to build a SUBREG to "convert" it to the wanted mode. That's
no use. Test for CONST_SCALAR_INT_P instead of CONST_INT_P so that we
skip the subreg creation for both.
Regstrapped on x86_64- and i686-linux-gnu. Ok to install?
for gcc/ChangeLog
PR rtl-optimization/87874
* lra.c (lra_substitute_pseudo): Do not create a subreg for
const wide ints.
for gcc/testsuite/ChangeLog
PR rtl-optimization/87874
* gcc.dg/pr87874.c: New.
---
gcc/lra.c | 2 +-
gcc/testsuite/gcc.dg/pr87874.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/pr87874.c
diff --git a/gcc/lra.c b/gcc/lra.c
index aa768fb2a231..5d58d90f3a6b 100644
--- a/gcc/lra.c
+++ b/gcc/lra.c
@@ -1961,7 +1961,7 @@ lra_substitute_pseudo (rtx *loc, int old_regno, rtx
new_reg, bool subreg_p,
machine_mode inner_mode = GET_MODE (new_reg);
if (mode != inner_mode
- && ! (CONST_INT_P (new_reg) && SCALAR_INT_MODE_P (mode)))
+ && ! (CONST_SCALAR_INT_P (new_reg) && SCALAR_INT_MODE_P (mode)))
{
poly_uint64 offset = 0;
if (partial_subreg_p (mode, inner_mode)
diff --git a/gcc/testsuite/gcc.dg/pr87874.c b/gcc/testsuite/gcc.dg/pr87874.c
new file mode 100644
index 000000000000..3ab5dcf68ffb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr87874.c
@@ -0,0 +1,35 @@
+/* { dg-do compile } */
+/* { dg-options "-g -O1 -fgcse -fno-dce -fno-tree-ccp -fno-tree-coalesce-vars
-fno-tree-copy-prop -fno-tree-dce -fno-tree-dominator-opts -fno-tree-fre
-fno-tree-loop-optimize -fno-tree-sink" } */
+
+int *vk;
+int m2;
+#if __SIZEOF_INT128__
+__int128 nb;
+
+void
+em (int u5, int fo, int s7)
+{
+ for (;;)
+ {
+ long int es;
+
+ es = !!u5 ? (!!fo && !!m2) : fo;
+ if (es == 0)
+ if (nb == *vk)
+ {
+ const unsigned long int uint64_max = 18446744073709551615ul;
+ __int128 ks = uint64_max / 2 + 1;
+
+ while (s7 < 1)
+ while (nb < 2)
+ {
+ for (ks = 0; ks < 3; ++ks)
+ {
+ }
+
+ ++nb;
+ }
+ }
+ }
+}
+#endif
--
Alexandre Oliva, freedom fighter https://FSFLA.org/blogs/lxo
Be the change, be Free! FSF Latin America board member
GNU Toolchain Engineer Free Software Evangelist
Hay que enGNUrecerse, pero sin perder la terGNUra jamás-GNUChe