* Another cprop trap_if fix, PR79125
@ 2017-01-20 12:29 Bernd Schmidt
2017-01-20 20:04 ` Jeff Law
2017-01-21 8:00 ` Jeff Law
0 siblings, 2 replies; 3+ messages in thread
From: Bernd Schmidt @ 2017-01-20 12:29 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 235 bytes --]
This is essentially the same patch I sent for the previous instance of
this problem, but this time applied to local_cprop_pass. Bootstrapped
and tested on x86_64-linux, and it seems to fix the testcase with a ppc
cross. Ok?
Bernd
[-- Attachment #2: pr79125.diff --]
[-- Type: text/x-patch, Size: 2279 bytes --]
PR rtl-optimization/79125
* cprop.c (local_cprop_pass): Handle cases where we make an
unconditional trap.
PR rtl-optimization/79125
* gcc.dg/torture/pr79125.c: New test.
Index: gcc/cprop.c
===================================================================
--- gcc/cprop.c (revision 244528)
+++ gcc/cprop.c (working copy)
@@ -1248,6 +1248,8 @@ local_cprop_pass (void)
bool changed = false;
unsigned i;
+ auto_vec<rtx_insn *> uncond_traps;
+
cselib_init (0);
FOR_EACH_BB_FN (bb, cfun)
{
@@ -1255,6 +1257,9 @@ local_cprop_pass (void)
{
if (INSN_P (insn))
{
+ bool was_uncond_trap
+ = (GET_CODE (PATTERN (insn)) == TRAP_IF
+ && XEXP (PATTERN (insn), 0) == const1_rtx);
rtx note = find_reg_equal_equiv_note (insn);
do
{
@@ -1273,6 +1278,13 @@ local_cprop_pass (void)
break;
}
}
+ if (!was_uncond_trap
+ && GET_CODE (PATTERN (insn)) == TRAP_IF
+ && XEXP (PATTERN (insn), 0) == const1_rtx)
+ {
+ uncond_traps.safe_push (insn);
+ break;
+ }
if (insn->deleted ())
break;
}
@@ -1287,6 +1299,14 @@ local_cprop_pass (void)
cselib_finish ();
+ while (!uncond_traps.is_empty ())
+ {
+ rtx_insn *insn = uncond_traps.pop ();
+ basic_block to_split = BLOCK_FOR_INSN (insn);
+ remove_edge (split_block (to_split, insn));
+ emit_barrier_after_bb (to_split);
+ }
+
return changed;
}
Index: gcc/testsuite/gcc.dg/torture/pr79125.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr79125.c (nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr79125.c (working copy)
@@ -0,0 +1,32 @@
+int za;
+
+void
+hl (void)
+{
+ short int o8 = 0;
+ short int m6 = 1;
+ short int *ni = &m6;
+
+ for (;;)
+ {
+ int af;
+ short int *fd = (short int *)∋
+
+ if (ni != 0)
+ {
+ if (m6 != 0)
+ *ni = 0;
+ else
+ za = 0;
+ af = (o8 * o8) || o8;
+ if (af == 0)
+ m6 /= 0; /* { dg-warning "division" } */
+ while (za != 0)
+ {
+ }
+ }
+ *fd = &o8; /* { dg-warning "without a cast" } */
+ for (af = 0; af < 2; ++af)
+ af = za;
+ }
+}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Another cprop trap_if fix, PR79125
2017-01-20 12:29 Another cprop trap_if fix, PR79125 Bernd Schmidt
@ 2017-01-20 20:04 ` Jeff Law
2017-01-21 8:00 ` Jeff Law
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Law @ 2017-01-20 20:04 UTC (permalink / raw)
To: Bernd Schmidt, GCC Patches
On 01/20/2017 05:24 AM, Bernd Schmidt wrote:
> This is essentially the same patch I sent for the previous instance of
> this problem, but this time applied to local_cprop_pass. Bootstrapped
> and tested on x86_64-linux, and it seems to fix the testcase with a ppc
> cross. Ok?
>
>
> Bernd
>
> pr79125.diff
>
>
> PR rtl-optimization/79125
> * cprop.c (local_cprop_pass): Handle cases where we make an
> unconditional trap.
>
> PR rtl-optimization/79125
> * gcc.dg/torture/pr79125.c: New test.
OK. Though part of me dislikes having this code appear twice, but I can
live with it.
jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Another cprop trap_if fix, PR79125
2017-01-20 12:29 Another cprop trap_if fix, PR79125 Bernd Schmidt
2017-01-20 20:04 ` Jeff Law
@ 2017-01-21 8:00 ` Jeff Law
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Law @ 2017-01-21 8:00 UTC (permalink / raw)
To: Bernd Schmidt, GCC Patches
On 01/20/2017 05:24 AM, Bernd Schmidt wrote:
> This is essentially the same patch I sent for the previous instance of
> this problem, but this time applied to local_cprop_pass. Bootstrapped
> and tested on x86_64-linux, and it seems to fix the testcase with a ppc
> cross. Ok?
>
>
> Bernd
>
> pr79125.diff
>
>
> PR rtl-optimization/79125
> * cprop.c (local_cprop_pass): Handle cases where we make an
> unconditional trap.
>
> PR rtl-optimization/79125
> * gcc.dg/torture/pr79125.c: New test.
I did a bootstrap and regression test on ppc64-linux and installed on
the trunk.
Thanks,
JEff
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-01-21 7:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-20 12:29 Another cprop trap_if fix, PR79125 Bernd Schmidt
2017-01-20 20:04 ` Jeff Law
2017-01-21 8:00 ` Jeff Law
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).