From c33db31d9ad96f6414460315c12b4b505fad5dd7 Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Wed, 21 Apr 2021 14:13:04 +0200 Subject: [PATCH] Fix target/100106 ICE in gen_movdi As the test case shows, the outer mode may have a higher alignment requirement than the inner mode here. 2021-04-27 Bernd Edlinger PR target/100106 * simplify-rtx.c (simplify_context::simplify_subreg): Check the memory alignment for the outer mode. * gcc.c-torture/compile/pr100106.c: New testcase. --- gcc/simplify-rtx.c | 1 + gcc/testsuite/gcc.c-torture/compile/pr100106.c | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr100106.c diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index d13c390a20cc..ad3b7b2d9d0e 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -7217,6 +7217,7 @@ simplify_context::simplify_subreg (machine_mode outermode, rtx op, have instruction to move the whole thing. */ && (! MEM_VOLATILE_P (op) || ! have_insn_for (SET, innermode)) + && !(STRICT_ALIGNMENT && MEM_ALIGN (op) < GET_MODE_ALIGNMENT (outermode)) && known_le (outersize, innersize)) return adjust_address_nv (op, outermode, byte); diff --git a/gcc/testsuite/gcc.c-torture/compile/pr100106.c b/gcc/testsuite/gcc.c-torture/compile/pr100106.c new file mode 100644 index 000000000000..7f98b4f992e0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr100106.c @@ -0,0 +1,11 @@ +union a { + float _Complex b; + long long c; +}; + +void g(union a); + +void e() { + union a f = {1.0f}; + g(f); +} -- 2.47.2