new file mode 100644
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-additional-options "--param logical-op-non-short-circuit=0" } */
+
+extern char **environ;
+static char ***p_environ = &environ;
+int
+_setenv_r (const char *name, const char *value)
+{
+ register char *C;
+ int offset;
+ for (C = (*p_environ)[offset]; (*C = *name++) && *C != '='; ++C);
+ for (*C++ = '='; (*C++ = *value++) != 0;);
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+extern void c();
+int a, b;
+int main() {
+ while (b) {
+ int d, e = 0, *f = &a;
+ *f = 1;
+ e = 1 >> d ? : 1 << d;
+ if (e)
+ a = 0;
+ c();
+ }
+ return 0;
+}
@@ -467,11 +467,17 @@ statement_sink_location (gimple *stmt, basic_block frombb,
if (!sinkbb)
return false;
- sinkbb = select_best_block (frombb, sinkbb, stmt);
- if (sinkbb == frombb)
+ basic_block bestbb = select_best_block (frombb, sinkbb, stmt);
+ if (bestbb == frombb
+ /* When we sink a store make sure there's not a path to any of
+ the possibly skipped killing defs as that wrecks the virtual
+ operand update, requiring inserting of a PHI node. */
+ || (gimple_vdef (stmt)
+ && bestbb != sinkbb
+ && !dominated_by_p (CDI_POST_DOMINATORS, bestbb, sinkbb)))
return false;
- *togsi = gsi_after_labels (sinkbb);
+ *togsi = gsi_after_labels (bestbb);
return true;
}