re PR rtl-optimization/62146 (CSE replaces constant with an expression incorrectly)
authorEaswaran Raman <eraman@google.com>
Fri, 5 Sep 2014 22:23:26 +0000 (22:23 +0000)
committerEaswaran Raman <eraman@gcc.gnu.org>
Fri, 5 Sep 2014 22:23:26 +0000 (22:23 +0000)
2014-09-05  Easwaran Raman  <eraman@google.com>

        PR rtl-optimization/62146
        * ifcvt.c (dead_or_predicable): Make removal of REG_EQUAL note of
          hoisted instruction unconditional.

        testsuite:
        * testsuite/g++.dg/opt/pr62146.C: New.

From-SVN: r214977

gcc/ChangeLog
gcc/ifcvt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr62146.C [new file with mode: 0644]

index 18951b3b47e589165c6b64020271d402a9808d33..07988cdc42c212ca6fda16cc2f07d98c81713e0b 100644 (file)
@@ -1,3 +1,9 @@
+2014-09-05  Easwaran Raman  <eraman@google.com>
+
+       PR rtl-optimization/62146
+       * ifcvt.c (dead_or_predicable): Make removal of REG_EQUAL note of
+       hoisted instruction unconditional.
+
 2014-09-05  Segher Boessenkool  <segher@kernel.crashing.org>
 
        PR target/63187
index eee04cc2d042f2289b52fb7163a4b7dff7130487..bce9fb3f0fedb604312cb6c438e495bc62a9f1bf 100644 (file)
@@ -4403,17 +4403,14 @@ dead_or_predicable (basic_block test_bb, basic_block merge_bb,
       insn = head;
       do
        {
-         rtx note, set;
+         rtx note;
 
          if (! INSN_P (insn))
            continue;
          note = find_reg_note (insn, REG_EQUAL, NULL_RTX);
          if (! note)
            continue;
-         set = single_set (insn);
-         if (!set || !function_invariant_p (SET_SRC (set))
-             || !function_invariant_p (XEXP (note, 0)))
-           remove_note (insn, note);
+         remove_note (insn, note);
        } while (insn != end && (insn = NEXT_INSN (insn)));
 
       /* PR46315: when moving insns above a conditional branch, the REG_EQUAL
index b6422c958ebc65ec47da607af0bbedbfae7df9f5..582f538857c4b200a2b583b3267b3b35af075942 100644 (file)
@@ -1,3 +1,8 @@
+2014-09-05  Easwaran Raman  <eraman@google.com>
+
+       PR rtl-optimization/62146
+       * testsuite/g++.dg/opt/pr62146.C: New.
+
 2014-09-05  Marat Zakirov  <m.zakirov@samsung.com>
 
        * gcc.dg/vect/vect-109.c: Skip predicate added.
diff --git a/gcc/testsuite/g++.dg/opt/pr62146.C b/gcc/testsuite/g++.dg/opt/pr62146.C
new file mode 100644 (file)
index 0000000..dbe4174
--- /dev/null
@@ -0,0 +1,51 @@
+/* PR rtl-optimization/62146 */
+/* { dg-do compile } */
+/* { dg-options "-O2 " } */
+class F
+{
+public:
+    virtual ~ F ();
+};
+template < class CL > class G:public F
+{
+    int *member_;
+public:
+    G ( int *b): member_ (0)
+    {
+    }
+};
+
+class D
+{
+public:
+    template < class CL > void RegisterNonTagCallback (int,
+            void (CL::
+                  *p3) ())
+    {
+        InternalRegisterNonTag (p3 ? new G < CL > ( 0) : 0);
+    } void InternalRegisterNonTag (F *);
+};
+
+void fn1 ();
+class C1
+{
+    void  foo();
+    class TokenType
+    {
+    public:
+        void AddToken ()
+        {
+        }
+    };
+    C1::TokenType bar_t;
+};
+D a;
+void C1::foo()
+{
+    if (&bar_t)
+        fn1 ();
+    for (int i = 0; i < sizeof 0; ++i)
+        a.RegisterNonTagCallback (0, &TokenType::AddToken);
+}
+
+/* { dg-final { scan-assembler-not "mov.*_ZN2C19TokenType8AddTokenEv, .\\\(" } } */