new file mode 100644
@@ -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;
+}
+
new file mode 100644
@@ -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();
+}
new file mode 100644
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+
+static int t;
+
+int f (int *a)
+{
+ int t1, t2 = 0;
+ asm ("shouldshowupstill %1" : "=r" (t1), "=m"(t2) : : );
+ t = t1;
+ return t2;
+}
+
+/* Check to make sure DCE does not remove the inline-asm as it writes to t2. */
+/* We used to DCE this inline-asm when removing the store to t. */
+/* { dg-final { scan-assembler "shouldshowupstill" } } */
+/* { dg-final { scan-tree-dump-times "shouldshowupstill" 1 "optimized" } } */
@@ -2062,9 +2062,9 @@ simple_dce_from_worklist (bitmap worklist)
/* The defining statement needs to be defining only this name.
ASM is the only statement that can define more than one
- (non-virtual) name. */
+ name. */
if (is_a<gasm *>(t)
- && !single_ssa_def_operand (t, SSA_OP_DEF))
+ && !single_ssa_def_operand (t, SSA_OP_ALL_DEFS))
continue;
/* Don't remove statements that are needed for non-call
@@ -2094,6 +2094,7 @@ simple_dce_from_worklist (bitmap worklist)
remove_phi_node (&gsi, true);
else
{
+ unlink_stmt_vdef (t);
gsi_remove (&gsi, true);
release_defs (t);
}