Vector indexing leaves us with ARRAY_REFs of VIEW_CONVERT_EXPRs,
sth which array_at_struct_end_p considers a array-at-struct-end
even when there's an underlying decl visible. The following fixes
the latter.
2021-05-17 Richard Biener <rguenther@suse.de>
PR middle-end/100582
* tree.c (array_at_struct_end_p): Get to the base of the
reference before looking for the underlying decl.
* gcc.target/i386/pr100582.c: New testcase.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O3 -mavx2" } */
+
+typedef unsigned char v32qi __attribute__((vector_size(32)));
+
+v32qi
+f2 (v32qi x, v32qi a, v32qi b)
+{
+ v32qi e;
+ for (int i = 0; i != 32; i++)
+ e[i] = x[i] ? a[i] : b[i];
+
+ return e;
+}
+
+/* { dg-final { scan-assembler-times "pblendvb" 1 } } */
|| ! TYPE_MAX_VALUE (TYPE_DOMAIN (atype)))
return true;
- if (TREE_CODE (ref) == MEM_REF
- && TREE_CODE (TREE_OPERAND (ref, 0)) == ADDR_EXPR)
- ref = TREE_OPERAND (TREE_OPERAND (ref, 0), 0);
-
/* If the reference is based on a declared entity, the size of the array
is constrained by its given domain. (Do not trust commons PR/69368). */
- if (DECL_P (ref)
+ ref = get_base_address (ref);
+ if (ref
+ && DECL_P (ref)
&& !(flag_unconstrained_commons
&& VAR_P (ref) && DECL_COMMON (ref))
&& DECL_SIZE_UNIT (ref)