[PATCH] D50979: Eliminate instances of `EmitScalarExpr(E->getArg(n))` in EmitX86BuiltinExpr().
Nico Weber via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 20 10:28:07 PDT 2018
thakis created this revision.
thakis added a reviewer: rnk.
Herald added a reviewer: javed.absar.
Herald added a subscriber: kristof.beyls.
EmitX86BuiltinExpr() emits all args into Ops at the beginning, so don't do that work again. No intended behavior change.
(TNorthover: EmitAArch64BuiltinExpr() also emits args into Ops before the big switch (with some more subtlety around the last arg that I don't understand), but then almost every switch case does `EmitScalarExpr(E->getArg(n))`. It's been like this since the commit that added the arm64 code. Was the Ops pushing code added later and all the EmitScalarExpr()s are now unneeded, or is some reason for this?)
https://reviews.llvm.org/D50979
Files:
clang/lib/CodeGen/CGBuiltin.cpp
Index: clang/lib/CodeGen/CGBuiltin.cpp
===================================================================
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -10480,14 +10480,11 @@
llvm::Type *Int128PtrTy = Int128Ty->getPointerTo();
Value *Destination =
- Builder.CreateBitCast(EmitScalarExpr(E->getArg(0)), Int128PtrTy);
- Value *ExchangeHigh128 =
- Builder.CreateZExt(EmitScalarExpr(E->getArg(1)), Int128Ty);
- Value *ExchangeLow128 =
- Builder.CreateZExt(EmitScalarExpr(E->getArg(2)), Int128Ty);
- Address ComparandResult(
- Builder.CreateBitCast(EmitScalarExpr(E->getArg(3)), Int128PtrTy),
- getContext().toCharUnitsFromBits(128));
+ Builder.CreateBitCast(Ops[0], Int128PtrTy);
+ Value *ExchangeHigh128 = Builder.CreateZExt(Ops[1], Int128Ty);
+ Value *ExchangeLow128 = Builder.CreateZExt(Ops[2], Int128Ty);
+ Address ComparandResult(Builder.CreateBitCast(Ops[3], Int128PtrTy),
+ getContext().toCharUnitsFromBits(128));
Value *Exchange = Builder.CreateOr(
Builder.CreateShl(ExchangeHigh128, 64, "", false, false),
@@ -10538,8 +10535,8 @@
case X86::BI__readfsdword:
case X86::BI__readfsqword: {
llvm::Type *IntTy = ConvertType(E->getType());
- Value *Ptr = Builder.CreateIntToPtr(EmitScalarExpr(E->getArg(0)),
- llvm::PointerType::get(IntTy, 257));
+ Value *Ptr =
+ Builder.CreateIntToPtr(Ops[0], llvm::PointerType::get(IntTy, 257));
LoadInst *Load = Builder.CreateAlignedLoad(
IntTy, Ptr, getContext().getTypeAlignInChars(E->getType()));
Load->setVolatile(true);
@@ -10550,8 +10547,8 @@
case X86::BI__readgsdword:
case X86::BI__readgsqword: {
llvm::Type *IntTy = ConvertType(E->getType());
- Value *Ptr = Builder.CreateIntToPtr(EmitScalarExpr(E->getArg(0)),
- llvm::PointerType::get(IntTy, 256));
+ Value *Ptr =
+ Builder.CreateIntToPtr(Ops[0], llvm::PointerType::get(IntTy, 256));
LoadInst *Load = Builder.CreateAlignedLoad(
IntTy, Ptr, getContext().getTypeAlignInChars(E->getType()));
Load->setVolatile(true);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50979.161505.patch
Type: text/x-patch
Size: 2218 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180820/288295ce/attachment-0001.bin>
More information about the cfe-commits
mailing list