On Mon, Feb 12, 2018 at 03:59:05PM +0000, Segher Boessenkool wrote:
> If there is a LOG_LINK between two insns, this means those two insns
> can be combined, as far as dataflow is concerned. There never should
> be a LOG_LINK between two unrelated insns. If there is one, combine
> will try to combine the insns without doing all the needed checks if
> the earlier destination is used before the later insn, etc.
>
> Unfortunately we do not update the LOG_LINKs correctly in some cases.
> This patch fixes at least some of those cases.
>
> This fixes the PR's testcase on aarch64. Also tested on 30+ cross
> compiler, and on powerpc64-linux {-m32,-m64}. Will test on x86_64
> as well before committing.
Will you check in the testcase too?
My preference would be something like following, so that it can
be torture-tested on all targets.
--- gcc/testsuite/gcc.c-torture/execute/pr84169.c 2018-01-12
10:39:42.940283691 +0100
+++ gcc/testsuite/gcc.c-torture/execute/pr84169.c 2018-02-12
17:11:18.970878978 +0100
@@ -0,0 +1,25 @@
+/* PR rtl-optimization/84169 */
+
+#ifdef __SIZEOF_INT128__
+typedef unsigned __int128 T;
+#else
+typedef unsigned long long T;
+#endif
+
+T b;
+
+static __attribute__ ((noipa)) T
+foo (T c, T d, T e, T f, T g, T h)
+{
+ __builtin_mul_overflow ((unsigned char) h, -16, &h);
+ return b + h;
+}
+
+int
+main ()
+{
+ T x = foo (0, 0, 0, 0, 0, 4);
+ if (x != -64)
+ __builtin_abort ();
+ return 0;
+}
Jakub