[cfe-commits] r151659 - /cfe/trunk/lib/CodeGen/CGClass.cpp

Eli Friedman eli.friedman at gmail.com
Tue Feb 28 14:07:56 PST 2012


Author: efriedma
Date: Tue Feb 28 16:07:56 2012
New Revision: 151659

URL: http://llvm.org/viewvc/llvm-project?rev=151659&view=rev
Log:
Prefer bitcast+GEP over ptrtoint+sub+inttoptr: it's semantically equivalent here, and generally nicer to the optimizer.


Modified:
    cfe/trunk/lib/CodeGen/CGClass.cpp

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=151659&r1=151658&r2=151659&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Tue Feb 28 16:07:56 2012
@@ -249,9 +249,9 @@
   }
   
   // Apply the offset.
-  Value = Builder.CreatePtrToInt(Value, NonVirtualOffset->getType());
-  Value = Builder.CreateSub(Value, NonVirtualOffset);
-  Value = Builder.CreateIntToPtr(Value, DerivedPtrTy);
+  Value = Builder.CreateBitCast(Value, Int8PtrTy);
+  Value = Builder.CreateGEP(Value, Builder.CreateNeg(NonVirtualOffset),
+                            "sub.ptr");
 
   // Just cast.
   Value = Builder.CreateBitCast(Value, DerivedPtrTy);





More information about the cfe-commits mailing list