On 10/6/26 7:50 AM, [email protected] wrote:
From: Kyrylo Tkachov <[email protected]>
simplify_binary_operation_1 simplifies the concatenation of the two
halves of an object to gen_lowpart of the object. get_ref_base_and_offset
can return any rtx as the object, such as an UNSPEC, but gen_lowpart
asserts for an UNSPEC in another mode.
For example, on AArch64 fwprop1 tries to propagate the result of an LD2
into the operands of an ADDP for:
uint8x8x2_t v = vld2_u8 (p);
return vpadd_u8 (v.val[0], v.val[1]);
The ADDP operands then contain:
(vec_concat:V16QI
(subreg:V8QI (unspec:V2x8QI [(mem:V2x8QI (reg:DI p))] UNSPEC_LD2_DREG) 0)
(subreg:V8QI (unspec:V2x8QI [(mem:V2x8QI (reg:DI p))] UNSPEC_LD2_DREG) 8))
and gen_lowpart (V16QImode, (unspec:V2x8QI ...)) fails the assert. The
x86_64 testcase in the PR reaches the fold through debug insns.
Use rtl_hooks.gen_lowpart_no_emit, like the other simplifications in this
file, and do not fold if it fails. Unlike gen_lowpart, the hook also
never emits instructions.
Bootstrapped and tested on x86_64-pc-linux-gnu.
Ok for trunk?
Thanks,
Kyrill
gcc/ChangeLog:
PR rtl-optimization/127483
* simplify-rtx.cc (simplify_context::simplify_binary_operation_1)
<case VEC_CONCAT>: Use rtl_hooks.gen_lowpart_no_emit rather than
gen_lowpart, and do not fold if it fails.
gcc/testsuite/ChangeLog:
PR rtl-optimization/127483
* gcc.dg/pr127483.c: New test.
* gcc.target/aarch64/pr127483.c: Likewise.
* gcc.target/aarch64/pr127483-be.c: Likewise.
Signed-off-by: Kyrylo Tkachov <[email protected]>
---
diff --git a/gcc/testsuite/gcc.dg/pr127483.c b/gcc/testsuite/gcc.dg/pr127483.c
new file mode 100644
index 00000000000..eb3530db77b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr127483.c
@@ -0,0 +1,16 @@
+/* PR rtl-optimization/127483 */
+/* { dg-do compile { target int128 } } */
+/* { dg-options "-Og -g" } */
+
+typedef __attribute__((__vector_size__(16))) char V;
I don't think you're using "V" anywhere, so you can just drop this.
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr127483-be.c
@@ -0,0 +1,7 @@
+/* PR rtl-optimization/127483 */
+/* { dg-do compile } */
+/* { dg-require-effective-target aarch64_mbig_endian } */
Should that be just aarch64_big_endian, without the "m"?
OK with the nits above fixed.
jeff