diff options
author | Andrew Pinski <apinski@marvell.com> | 2023-02-07 23:09:40 +0000 |
---|---|---|
committer | Andrew Pinski <apinski@marvell.com> | 2023-02-09 17:47:05 -0800 |
commit | 6a5cb782d1486b378d70857c8efae558da0eb2cc (patch) | |
tree | 933272dcb4a22f6fa1e468d4a93171c3d860bc61 /gcc/testsuite/gcc.c-torture | |
parent | b9f8935e110c392c21460db838b4209c32f070c2 (diff) | |
download | gcc-6a5cb782d1486b378d70857c8efae558da0eb2cc.zip gcc-6a5cb782d1486b378d70857c8efae558da0eb2cc.tar.gz gcc-6a5cb782d1486b378d70857c8efae558da0eb2cc.tar.bz2 |
tree-optimization: [PR108684] ICE in verify_ssa due to simple_dce_from_worklist
In simple_dce_from_worklist, we were removing an inline-asm which had a vdef.
We should not be removing inline-asm which have a vdef as this code
does not check to the store.
This fixes that oversight. This was a latent bug exposed recently
by both VRP and removal of stores to static starting to use
simple_dce_from_worklist.
Committed as approved.
Bootstrapped and tested on x86_64-linux-gnu with no regressions.
PR tree-optimization/108684
gcc/ChangeLog:
* tree-ssa-dce.cc (simple_dce_from_worklist):
Check all ssa names and not just non-vdef ones
before accepting the inline-asm.
Call unlink_stmt_vdef on the statement before
removing it.
gcc/testsuite/ChangeLog:
* gcc.c-torture/compile/dce-inline-asm-1.c: New test.
* gcc.c-torture/compile/dce-inline-asm-2.c: New test.
* gcc.dg/tree-ssa/pr108684-1.c: New test.
co-authored-by: Andrew Macleod <amacleod@redhat.com>
Diffstat (limited to 'gcc/testsuite/gcc.c-torture')
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/dce-inline-asm-1.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/dce-inline-asm-2.c | 16 |
2 files changed, 31 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/compile/dce-inline-asm-1.c b/gcc/testsuite/gcc.c-torture/compile/dce-inline-asm-1.c new file mode 100644 index 0000000..a9f02e4 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/dce-inline-asm-1.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/108684 */ +/* This used to ICE as when we remove the store to + `t`, we also would remove the inline-asm which + had a VDEF on it but we didn't update the + VUSE that was later on. */ +static int t; + +int f (int *a) +{ + int t1; + asm (" " : "=X" (t1) : : "memory"); + t = t1; + return *a; +} + diff --git a/gcc/testsuite/gcc.c-torture/compile/dce-inline-asm-2.c b/gcc/testsuite/gcc.c-torture/compile/dce-inline-asm-2.c new file mode 100644 index 0000000..a41b16e --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/dce-inline-asm-2.c @@ -0,0 +1,16 @@ +/* PR tree-optimization/108684 */ +/* This used to ICE as when we removed the + __builtin_unreachable in VRP, as we + would also remove the branch and the + inline-asm. The inline-asm had a VDEF on it, + which we didn't update further along and + not have the VDEF on the return statement + updated. */ + +int f (int a) +{ + asm (" " : "=X" (a) : : "memory"); + if (a) + return 0; + __builtin_unreachable(); +} |