]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add an IR folding rule to convert Add32(x,x) into Shl32(x,1). This
authorJulian Seward <jseward@acm.org>
Sun, 14 May 2006 18:46:55 +0000 (18:46 +0000)
committerJulian Seward <jseward@acm.org>
Sun, 14 May 2006 18:46:55 +0000 (18:46 +0000)
fixes #118466 and it also gets rid of a bunch of false positives for
KDE 3.5.2 built by gcc-4.0.2 on x86, of the form shown below.

  Use of uninitialised value of size 4
    at 0x4BFC342: QIconSet::pixmap(QIconSet::Size, QIconSet::Mode,
                                   QIconSet::State) const (qiconset.cpp:530)
    by 0x4555BE7: KToolBarButton::drawButton(QPainter*)
                  (ktoolbarbutton.cpp:536)
    by 0x4CB8A0A: QButton::paintEvent(QPaintEvent*) (qbutton.cpp:887)

git-svn-id: svn://svn.valgrind.org/vex/trunk@1617

VEX/priv/ir/iropt.c

index fd981ab503b2011267668bbc690ac6b04ae2cdcf..94462d40218272a7f2563f2ca43d359e353b85e3 100644 (file)
@@ -1405,6 +1405,20 @@ static IRExpr* fold_Expr ( IRExpr* e )
             e2 = e->Iex.Binop.arg1;
          } else
 
+         /* Add32(t,t) ==> t << 1.  Memcheck doesn't understand that
+            x+x produces a defined least significant bit, and it seems
+            simplest just to get rid of the problem by rewriting it
+            out, since the opportunity to do so exists. */
+         if (e->Iex.Binop.op == Iop_Add32
+             && e->Iex.Binop.arg1->tag == Iex_Tmp
+             && e->Iex.Binop.arg2->tag == Iex_Tmp
+             && e->Iex.Binop.arg1->Iex.Tmp.tmp 
+                == e->Iex.Binop.arg2->Iex.Tmp.tmp) {
+            e2 = IRExpr_Binop(Iop_Shl32,
+                              e->Iex.Binop.arg1,
+                              IRExpr_Const(IRConst_U8(1)));
+         } else
+
          /* Or64/Add64(x,0) ==> x */
          if ((e->Iex.Binop.op == Iop_Add64 || e->Iex.Binop.op == Iop_Or64)
              && e->Iex.Binop.arg2->tag == Iex_Const