From 03d6d755c70a1b4c760501de0c740365e497331d Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 23 Jan 2020 19:38:10 -0500 Subject: [PATCH] add patch fixing gcc pr93402 (wrong codegen) affects all gcc versions 6.x and later. same patch works for all. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93402 --- patches/gcc-6.5.0/0023-pr93402.diff | 45 +++++++++++++++++++++++++++++ patches/gcc-7.3.0/0020-pr93402.diff | 45 +++++++++++++++++++++++++++++ patches/gcc-8.3.0/0017-pr93402.diff | 45 +++++++++++++++++++++++++++++ patches/gcc-9.2.0/0017-pr93402.diff | 45 +++++++++++++++++++++++++++++ 4 files changed, 180 insertions(+) create mode 100644 patches/gcc-6.5.0/0023-pr93402.diff create mode 100644 patches/gcc-7.3.0/0020-pr93402.diff create mode 100644 patches/gcc-8.3.0/0017-pr93402.diff create mode 100644 patches/gcc-9.2.0/0017-pr93402.diff diff --git a/patches/gcc-6.5.0/0023-pr93402.diff b/patches/gcc-6.5.0/0023-pr93402.diff new file mode 100644 index 0000000..c985fb6 --- /dev/null +++ b/patches/gcc-6.5.0/0023-pr93402.diff @@ -0,0 +1,45 @@ +2020-01-23 Jakub Jelinek + + PR rtl-optimization/93402 + * postreload.c (reload_combine_recognize_pattern): Don't try to adjust + USE insns. + + * gcc.c-torture/execute/pr93402.c: New test. + +--- a/gcc/postreload.c.jj 2020-01-12 11:54:36.000000000 +0100 ++++ b/gcc/postreload.c 2020-01-23 17:23:25.359929516 +0100 +@@ -1078,6 +1078,10 @@ reload_combine_recognize_pattern (rtx_in + struct reg_use *use = reg_state[regno].reg_use + i; + if (GET_MODE (*use->usep) != mode) + return false; ++ /* Don't try to adjust (use (REGX)). */ ++ if (GET_CODE (PATTERN (use->insn)) == USE ++ && &XEXP (PATTERN (use->insn), 0) == use->usep) ++ return false; + } + + /* Look for (set (REGX) (CONST_INT)) +--- a/gcc/testsuite/gcc.c-torture/execute/pr93402.c.jj 2020-01-23 17:25:46.496803852 +0100 ++++ b/gcc/testsuite/gcc.c-torture/execute/pr93402.c 2020-01-23 17:25:05.221425501 +0100 +@@ -0,0 +1,21 @@ ++/* PR rtl-optimization/93402 */ ++ ++struct S { unsigned int a; unsigned long long b; }; ++ ++__attribute__((noipa)) struct S ++foo (unsigned long long x) ++{ ++ struct S ret; ++ ret.a = 0; ++ ret.b = x * 11111111111ULL + 111111111111ULL; ++ return ret; ++} ++ ++int ++main () ++{ ++ struct S a = foo (1); ++ if (a.a != 0 || a.b != 122222222222ULL) ++ __builtin_abort (); ++ return 0; ++} diff --git a/patches/gcc-7.3.0/0020-pr93402.diff b/patches/gcc-7.3.0/0020-pr93402.diff new file mode 100644 index 0000000..c985fb6 --- /dev/null +++ b/patches/gcc-7.3.0/0020-pr93402.diff @@ -0,0 +1,45 @@ +2020-01-23 Jakub Jelinek + + PR rtl-optimization/93402 + * postreload.c (reload_combine_recognize_pattern): Don't try to adjust + USE insns. + + * gcc.c-torture/execute/pr93402.c: New test. + +--- a/gcc/postreload.c.jj 2020-01-12 11:54:36.000000000 +0100 ++++ b/gcc/postreload.c 2020-01-23 17:23:25.359929516 +0100 +@@ -1078,6 +1078,10 @@ reload_combine_recognize_pattern (rtx_in + struct reg_use *use = reg_state[regno].reg_use + i; + if (GET_MODE (*use->usep) != mode) + return false; ++ /* Don't try to adjust (use (REGX)). */ ++ if (GET_CODE (PATTERN (use->insn)) == USE ++ && &XEXP (PATTERN (use->insn), 0) == use->usep) ++ return false; + } + + /* Look for (set (REGX) (CONST_INT)) +--- a/gcc/testsuite/gcc.c-torture/execute/pr93402.c.jj 2020-01-23 17:25:46.496803852 +0100 ++++ b/gcc/testsuite/gcc.c-torture/execute/pr93402.c 2020-01-23 17:25:05.221425501 +0100 +@@ -0,0 +1,21 @@ ++/* PR rtl-optimization/93402 */ ++ ++struct S { unsigned int a; unsigned long long b; }; ++ ++__attribute__((noipa)) struct S ++foo (unsigned long long x) ++{ ++ struct S ret; ++ ret.a = 0; ++ ret.b = x * 11111111111ULL + 111111111111ULL; ++ return ret; ++} ++ ++int ++main () ++{ ++ struct S a = foo (1); ++ if (a.a != 0 || a.b != 122222222222ULL) ++ __builtin_abort (); ++ return 0; ++} diff --git a/patches/gcc-8.3.0/0017-pr93402.diff b/patches/gcc-8.3.0/0017-pr93402.diff new file mode 100644 index 0000000..c985fb6 --- /dev/null +++ b/patches/gcc-8.3.0/0017-pr93402.diff @@ -0,0 +1,45 @@ +2020-01-23 Jakub Jelinek + + PR rtl-optimization/93402 + * postreload.c (reload_combine_recognize_pattern): Don't try to adjust + USE insns. + + * gcc.c-torture/execute/pr93402.c: New test. + +--- a/gcc/postreload.c.jj 2020-01-12 11:54:36.000000000 +0100 ++++ b/gcc/postreload.c 2020-01-23 17:23:25.359929516 +0100 +@@ -1078,6 +1078,10 @@ reload_combine_recognize_pattern (rtx_in + struct reg_use *use = reg_state[regno].reg_use + i; + if (GET_MODE (*use->usep) != mode) + return false; ++ /* Don't try to adjust (use (REGX)). */ ++ if (GET_CODE (PATTERN (use->insn)) == USE ++ && &XEXP (PATTERN (use->insn), 0) == use->usep) ++ return false; + } + + /* Look for (set (REGX) (CONST_INT)) +--- a/gcc/testsuite/gcc.c-torture/execute/pr93402.c.jj 2020-01-23 17:25:46.496803852 +0100 ++++ b/gcc/testsuite/gcc.c-torture/execute/pr93402.c 2020-01-23 17:25:05.221425501 +0100 +@@ -0,0 +1,21 @@ ++/* PR rtl-optimization/93402 */ ++ ++struct S { unsigned int a; unsigned long long b; }; ++ ++__attribute__((noipa)) struct S ++foo (unsigned long long x) ++{ ++ struct S ret; ++ ret.a = 0; ++ ret.b = x * 11111111111ULL + 111111111111ULL; ++ return ret; ++} ++ ++int ++main () ++{ ++ struct S a = foo (1); ++ if (a.a != 0 || a.b != 122222222222ULL) ++ __builtin_abort (); ++ return 0; ++} diff --git a/patches/gcc-9.2.0/0017-pr93402.diff b/patches/gcc-9.2.0/0017-pr93402.diff new file mode 100644 index 0000000..c985fb6 --- /dev/null +++ b/patches/gcc-9.2.0/0017-pr93402.diff @@ -0,0 +1,45 @@ +2020-01-23 Jakub Jelinek + + PR rtl-optimization/93402 + * postreload.c (reload_combine_recognize_pattern): Don't try to adjust + USE insns. + + * gcc.c-torture/execute/pr93402.c: New test. + +--- a/gcc/postreload.c.jj 2020-01-12 11:54:36.000000000 +0100 ++++ b/gcc/postreload.c 2020-01-23 17:23:25.359929516 +0100 +@@ -1078,6 +1078,10 @@ reload_combine_recognize_pattern (rtx_in + struct reg_use *use = reg_state[regno].reg_use + i; + if (GET_MODE (*use->usep) != mode) + return false; ++ /* Don't try to adjust (use (REGX)). */ ++ if (GET_CODE (PATTERN (use->insn)) == USE ++ && &XEXP (PATTERN (use->insn), 0) == use->usep) ++ return false; + } + + /* Look for (set (REGX) (CONST_INT)) +--- a/gcc/testsuite/gcc.c-torture/execute/pr93402.c.jj 2020-01-23 17:25:46.496803852 +0100 ++++ b/gcc/testsuite/gcc.c-torture/execute/pr93402.c 2020-01-23 17:25:05.221425501 +0100 +@@ -0,0 +1,21 @@ ++/* PR rtl-optimization/93402 */ ++ ++struct S { unsigned int a; unsigned long long b; }; ++ ++__attribute__((noipa)) struct S ++foo (unsigned long long x) ++{ ++ struct S ret; ++ ret.a = 0; ++ ret.b = x * 11111111111ULL + 111111111111ULL; ++ return ret; ++} ++ ++int ++main () ++{ ++ struct S a = foo (1); ++ if (a.a != 0 || a.b != 122222222222ULL) ++ __builtin_abort (); ++ return 0; ++}