]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
s390x: Don't emit "vector or with complement" on z13
authorAndreas Arnez <arnez@linux.ibm.com>
Mon, 7 Jun 2021 12:01:53 +0000 (14:01 +0200)
committerAndreas Arnez <arnez@linux.ibm.com>
Mon, 7 Jun 2021 13:37:32 +0000 (15:37 +0200)
The z/Architecture instruction "vector or with complement" (VOC) can be
used as an optimization to combine "vector or" with "vector nor".  This is
exploited in Valgrind since commit 6c1cb1a0128b00858b973e.  However, VOC
requires the vector-enhancements facility 1, which is not installed on a
z13 CPU.  Thus Valgrind can now run into SIGILL on z13 when trying to
execute vector string instructions.

Fix this by suppressing the VOC optimization unless the
vector-enhancements facility 1 is recognized on the host.

VEX/priv/host_s390_isel.c

index ee20c67115c40b13086607b971eb7dc783bab4fe..15ca92a6b3533ee245519ed505e9665e8071773b 100644 (file)
@@ -4102,14 +4102,17 @@ s390_isel_vec_expr_wrk(ISelEnv *env, IRExpr *expr)
       case Iop_OrV128:
          size = 16;
          vec_binop = S390_VEC_OR;
-         if (arg1->tag == Iex_Unop && arg1->Iex.Unop.op == Iop_NotV128) {
-            IRExpr* orig_arg1 = arg1;
-            arg1 = arg2;
-            arg2 = orig_arg1->Iex.Unop.arg;
-            vec_binop = S390_VEC_ORC;
-         } else if (arg2->tag == Iex_Unop && arg2->Iex.Unop.op == Iop_NotV128) {
-            arg2 = arg2->Iex.Unop.arg;
-            vec_binop = S390_VEC_ORC;
+         if (s390_host_has_vxe) {
+            if (arg1->tag == Iex_Unop && arg1->Iex.Unop.op == Iop_NotV128) {
+               IRExpr* orig_arg1 = arg1;
+               arg1 = arg2;
+               arg2 = orig_arg1->Iex.Unop.arg;
+               vec_binop = S390_VEC_ORC;
+            } else if (arg2->tag == Iex_Unop &&
+                       arg2->Iex.Unop.op == Iop_NotV128) {
+               arg2 = arg2->Iex.Unop.arg;
+               vec_binop = S390_VEC_ORC;
+            }
          }
          goto Iop_VV_wrk;