diff options
| author | Craig Topper <craig.topper@intel.com> | 2018-07-05 20:38:31 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@intel.com> | 2018-07-05 20:38:31 +0000 |
| commit | 284c5f342cd93e16db554e5490464ab5672b9285 (patch) | |
| tree | c68b07115072f97ce3511b4dc4d5ac75c4254d38 /clang/lib/CodeGen | |
| parent | e2c10f8f4750ca112112d8825b503de2241af204 (diff) | |
| download | bcm5719-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.cpp | 12 |
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); } } |

