]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add a couple more constant folding rules for vectors.
authorJulian Seward <jseward@acm.org>
Thu, 3 Apr 2014 13:48:21 +0000 (13:48 +0000)
committerJulian Seward <jseward@acm.org>
Thu, 3 Apr 2014 13:48:21 +0000 (13:48 +0000)
git-svn-id: svn://svn.valgrind.org/vex/trunk@2844

VEX/priv/ir_opt.c

index 1be5303c8ceebc923bffc45043e279687e5486bd..03a06e30541fec9c4d6c3a9ca4c8c373b14a5453 100644 (file)
@@ -1251,7 +1251,8 @@ static IRExpr* mkZeroOfPrimopResultType ( IROp op )
       case Iop_And64:
       case Iop_Sub64:
       case Iop_Xor64: return IRExpr_Const(IRConst_U64(0));
-      case Iop_XorV128: return IRExpr_Const(IRConst_V128(0));
+      case Iop_XorV128:
+      case Iop_AndV128: return IRExpr_Const(IRConst_V128(0));
       default: vpanic("mkZeroOfPrimopResultType: bad primop");
    }
 }
@@ -2150,6 +2151,13 @@ static IRExpr* fold_Expr ( IRExpr** env, IRExpr* e )
                   break;
                }
                break;
+            case Iop_Sub8x16:
+               /* Sub8x16(x,0) ==> x */
+               if (isZeroV128(e->Iex.Binop.arg2)) {
+                  e2 = e->Iex.Binop.arg1;
+                  break;
+               }
+               break;
 
             case Iop_And64:
             case Iop_And32:
@@ -2185,13 +2193,18 @@ static IRExpr* fold_Expr ( IRExpr** env, IRExpr* e )
                   e2 = e->Iex.Binop.arg1;
                   break;
                }
-               if (/* could handle other And cases here too, but so
-                      far not */
-                   e->Iex.Binop.op == Iop_And64
+               /* Deal with either arg zero.  Could handle other And
+                  cases here too. */
+               if (e->Iex.Binop.op == Iop_And64
                    && (isZeroU64(e->Iex.Binop.arg1)
                        || isZeroU64(e->Iex.Binop.arg2))) {
                   e2 =  mkZeroOfPrimopResultType(e->Iex.Binop.op);
                   break;
+               } else if (e->Iex.Binop.op == Iop_AndV128
+                          && (isZeroV128(e->Iex.Binop.arg1)
+                              || isZeroV128(e->Iex.Binop.arg2))) {
+                  e2 =  mkZeroOfPrimopResultType(e->Iex.Binop.op);
+                  break;
                }
                break;