2016-05-02 Jakub Jelinek <jakub@redhat.com>
+ PR rtl-optimization/70467
+ * cse.c (cse_insn): Handle no-op MEM moves after folding.
+
PR rtl-optimization/70467
* ipa-pure-const.c (check_call): Handle internal calls even in
ipa mode like in local mode.
for (i = 0; i < n_sets; i++)
{
bool repeat = false;
+ bool mem_noop_insn = false;
rtx src, dest;
rtx src_folded;
struct table_elt *elt = 0, *p;
}
/* Avoid creation of overlapping memory moves. */
- if (MEM_P (trial) && MEM_P (SET_DEST (sets[i].rtl)))
+ if (MEM_P (trial) && MEM_P (dest) && !rtx_equal_p (trial, dest))
{
rtx src, dest;
break;
}
+ /* Similarly, lots of targets don't allow no-op
+ (set (mem x) (mem x)) moves. */
+ else if (n_sets == 1
+ && MEM_P (trial)
+ && MEM_P (dest)
+ && rtx_equal_p (trial, dest)
+ && !side_effects_p (dest)
+ && (cfun->can_delete_dead_exceptions
+ || insn_nothrow_p (insn)))
+ {
+ SET_SRC (sets[i].rtl) = trial;
+ mem_noop_insn = true;
+ break;
+ }
+
/* Reject certain invalid forms of CONST that we create. */
else if (CONSTANT_P (trial)
&& GET_CODE (trial) == CONST
sets[i].rtl = 0;
}
+ /* Similarly for no-op MEM moves. */
+ else if (mem_noop_insn)
+ {
+ if (cfun->can_throw_non_call_exceptions && can_throw_internal (insn))
+ cse_cfg_altered = true;
+ delete_insn_and_edges (insn);
+ /* No more processing for this set. */
+ sets[i].rtl = 0;
+ }
+
/* If this SET is now setting PC to a label, we know it used to
be a conditional or computed branch. */
else if (dest == pc_rtx && GET_CODE (src) == LABEL_REF
+2016-05-02 Jakub Jelinek <jakub@redhat.com>
+
+ PR rtl-optimization/70467
+ * gcc.target/i386/pr70467-1.c: New test.
+
2016-05-02 Bernd Edlinger <bernd.edlinger@hotmail.de>
* gcc.dg/spec-options.c: Run the test on all targets.
--- /dev/null
+/* PR rtl-optimization/70467 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -mno-sse" } */
+
+void foo (unsigned long long *);
+
+void
+bar (void)
+{
+ unsigned long long a;
+ foo (&a);
+ a &= 0x7fffffffffffffffULL;
+ foo (&a);
+ a &= 0xffffffff7fffffffULL;
+ foo (&a);
+ a &= 0x7fffffff00000000ULL;
+ foo (&a);
+ a &= 0x000000007fffffffULL;
+ foo (&a);
+ a &= 0x00000000ffffffffULL;
+ foo (&a);
+ a &= 0xffffffff00000000ULL;
+ foo (&a);
+ a |= 0x7fffffffffffffffULL;
+ foo (&a);
+ a |= 0xffffffff7fffffffULL;
+ foo (&a);
+ a |= 0x7fffffff00000000ULL;
+ foo (&a);
+ a |= 0x000000007fffffffULL;
+ foo (&a);
+ a |= 0x00000000ffffffffULL;
+ foo (&a);
+ a |= 0xffffffff00000000ULL;
+ foo (&a);
+ a ^= 0x7fffffffffffffffULL;
+ foo (&a);
+ a ^= 0xffffffff7fffffffULL;
+ foo (&a);
+ a ^= 0x7fffffff00000000ULL;
+ foo (&a);
+ a ^= 0x000000007fffffffULL;
+ foo (&a);
+ a ^= 0x00000000ffffffffULL;
+ foo (&a);
+ a ^= 0xffffffff00000000ULL;
+ foo (&a);
+}
+
+/* { dg-final { scan-assembler-not "andl\[ \t\]*.-1," { target ia32 } } } */
+/* { dg-final { scan-assembler-not "andl\[ \t\]*.0," { target ia32 } } } */
+/* { dg-final { scan-assembler-not "orl\[ \t\]*.-1," { target ia32 } } } */
+/* { dg-final { scan-assembler-not "orl\[ \t\]*.0," { target ia32 } } } */
+/* { dg-final { scan-assembler-not "xorl\[ \t\]*.-1," { target ia32 } } } */
+/* { dg-final { scan-assembler-not "xorl\[ \t\]*.0," { target ia32 } } } */