public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Cc: richard.sandiford@arm.com, vmakarov@redhat.com
Subject: [PATCH] rtl-optimization/119689 - compare-debug failure with LRA
Date: Wed, 9 Apr 2025 14:40:18 +0200 (CEST)	[thread overview]
Message-ID: <20250409124018.R4J_6bGlxGGDb4MRmq3_nKa5BMDlxJ9RZybNrpR3J58@z> (raw)

The previous change to fix LRA rematerialization broke compare-debug
for i586 bootstrap.  Fixed by using prev_nonnote_nondebug_insn
instead of prev_nonnote_insn.

Bootstrapped on i586-linux where the miscompare is gone with this
patch.  Bootstrap and regtest running on x86_64-unknown-linux-gnu.

OK if the latter succeeds?

Thanks,
Richard.

	PR rtl-optimization/119689
	PR rtl-optimization/115568
	* lra-remat.cc (create_cands): Use prev_nonnote_nondebug_insn
	to check whether insn2 is directly before insn.

	* g++.target/i386/pr119689.C: New testcase.
---
 gcc/lra-remat.cc                         |  2 +-
 gcc/testsuite/g++.target/i386/pr119689.C | 44 ++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.target/i386/pr119689.C

diff --git a/gcc/lra-remat.cc b/gcc/lra-remat.cc
index 2f3afffcf5b..5f823193aa7 100644
--- a/gcc/lra-remat.cc
+++ b/gcc/lra-remat.cc
@@ -460,7 +460,7 @@ create_cands (void)
 		&& dst_regno >= FIRST_PSEUDO_REGISTER
 		&& reg_renumber[dst_regno] < 0
 		&& BLOCK_FOR_INSN (insn2) == BLOCK_FOR_INSN (insn)
-		&& insn2 == prev_nonnote_insn (insn))
+		&& insn2 == prev_nonnote_nondebug_insn (insn))
 	      {
 		create_cand (insn2, regno_potential_cand[src_regno].nop,
 			     dst_regno, insn);
diff --git a/gcc/testsuite/g++.target/i386/pr119689.C b/gcc/testsuite/g++.target/i386/pr119689.C
new file mode 100644
index 00000000000..cdc6d2dade5
--- /dev/null
+++ b/gcc/testsuite/g++.target/i386/pr119689.C
@@ -0,0 +1,44 @@
+// { dg-do compile }
+// { dg-options "-O2 -fcompare-debug" }
+// { dg-additional-options "-march=i586 -mtune=generic" { target ia32 } }
+// { dg-additional-options "-fPIC" { target { fpic } } }
+
+enum gimple_code { GIMPLE_ASSIGN, GIMPLE_RETURN };
+bool is_gimple_call();
+int m_sig, m_exp, sreal_new_exp;
+struct sreal {
+  sreal(long long sig) {
+    long long __trans_tmp_6 = sig >= 0 ? sig : -(unsigned long long)sig;
+    sig = __trans_tmp_6 <<= sreal_new_exp -= m_exp = __trans_tmp_6;
+    m_sig = sig;
+  }
+  void operator/(sreal);
+};
+struct ipa_predicate {
+  ipa_predicate(bool = true);
+  void operator&=(ipa_predicate);
+  void operator&(ipa_predicate);
+};
+void add_condition();
+gimple_code eliminated_by_inlining_prob_code;
+static int eliminated_by_inlining_prob() {
+  switch (eliminated_by_inlining_prob_code) {
+  case GIMPLE_RETURN:
+    return 2;
+  case GIMPLE_ASSIGN:
+    return 1;
+  }
+  return 0;
+}
+void fp_expression_p() {
+  ipa_predicate bb_predicate;
+  for (;;) {
+    int prob = eliminated_by_inlining_prob();
+    ipa_predicate sra_predicate;
+    sra_predicate &= add_condition;
+    if (is_gimple_call())
+      sreal(prob) / 2;
+    if (prob != 2)
+      bb_predicate & sra_predicate;
+  }
+}
-- 
2.43.0

             reply	other threads:[~2025-04-09 12:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-09 12:40 Richard Biener [this message]
     [not found] <15928.125040908470202165@us-mta-590.us.mimecast.lan>
2025-04-09 13:10 ` Vladimir Makarov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250409124018.R4J_6bGlxGGDb4MRmq3_nKa5BMDlxJ9RZybNrpR3J58@z \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.sandiford@arm.com \
    --cc=vmakarov@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).