if ((flags & VEC_ANY_SVE) && !TARGET_SVE2)
return false;
+ int pow = wi::exact_log2 (cst + 1);
+ auto insn_code = maybe_code_for_aarch64_bitmask_udiv3 (TYPE_MODE (vectype));
+ /* SVE actually has a div operator, we may have gotten here through
+ that route. */
+ if (pow != (int) (element_precision (vectype) / 2)
+ || insn_code == CODE_FOR_nothing)
+ return false;
+
+ /* We can use the optimized pattern. */
if (in0 == NULL_RTX && in1 == NULL_RTX)
- {
- wide_int val = wi::add (cst, 1);
- int pow = wi::exact_log2 (val);
- return pow == (int)(element_precision (vectype) / 2);
- }
+ return true;
if (!VECTOR_TYPE_P (vectype))
return false;
--- /dev/null
+/* { dg-do compile } */
+/* { dg-require-effective-target fopenmp } */
+/* { dg-additional-options "-Os -fopenmp" } */
+
+void
+f2 (int *a)
+{
+ unsigned int i;
+
+#pragma omp simd
+ for (i = 0; i < 4; ++i)
+ a[i / 3] -= 4;
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-additional-options "-O3 -msve-vector-bits=512" } */
+
+void f(unsigned short *restrict p1, unsigned int *restrict p2)
+{
+ for (int i = 0; i < 16; ++i)
+ {
+ p1[i] /= 0xff;
+ p2[i] += 1;
+ }
+}
+