summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2018-07-05 20:38:31 +0000
committerCraig Topper <craig.topper@intel.com>2018-07-05 20:38:31 +0000
commit284c5f342cd93e16db554e5490464ab5672b9285 (patch)
treec68b07115072f97ce3511b4dc4d5ac75c4254d38 /clang/lib/CodeGen
parente2c10f8f4750ca112112d8825b503de2241af204 (diff)
downloadbcm5719-llvm-284c5f342cd93e16db554e5490464ab5672b9285.tar.gz
bcm5719-llvm-284c5f342cd93e16db554e5490464ab5672b9285.zip
[X86] Use shufflevector instead of a select with a constant mask for fmaddsub/fmsubadd IR emission.
Shufflevector is easier to generate and matches what the backend pattern matches without relying on constant selects being turned into shuffles. While I was there I also made the IR regular expressions a little stricter to ensure operand order on the shuffle. llvm-svn: 336388
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGBuiltin.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 6edb802d91e..56cf6a99524 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -8660,17 +8660,13 @@ static Value *EmitX86FMAExpr(CodeGenFunction &CGF, ArrayRef<Value *> Ops,
if (IsAddSub) {
// Negate even elts in C using a mask.
unsigned NumElts = Ty->getVectorNumElements();
- SmallVector<Constant *, 16> NMask;
- Constant *Zero = ConstantInt::get(CGF.Builder.getInt1Ty(), 0);
- Constant *One = ConstantInt::get(CGF.Builder.getInt1Ty(), 1);
- for (unsigned i = 0; i < NumElts; ++i) {
- NMask.push_back(i % 2 == 0 ? One : Zero);
- }
- Value *NegMask = ConstantVector::get(NMask);
+ SmallVector<uint32_t, 16> Indices(NumElts);
+ for (unsigned i = 0; i != NumElts; ++i)
+ Indices[i] = i + (i % 2) * NumElts;
Value *NegC = CGF.Builder.CreateFNeg(C);
Value *FMSub = CGF.Builder.CreateCall(FMA, {A, B, NegC} );
- Res = CGF.Builder.CreateSelect(NegMask, FMSub, Res);
+ Res = CGF.Builder.CreateShuffleVector(FMSub, Res, Indices);
}
}
OpenPOWER on IntegriCloud