[llvm] 96e0f34 - [X86] Auto upgrade SSE/AVX PABS intrinsics to generic Intrinsic::abs
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 7 07:10:25 PDT 2020
Author: Simon Pilgrim
Date: 2020-09-07T15:07:26+01:00
New Revision: 96e0f34be797ab8bb80526367009495a7eb2118f
URL: https://github.com/llvm/llvm-project/commit/96e0f34be797ab8bb80526367009495a7eb2118f
DIFF: https://github.com/llvm/llvm-project/commit/96e0f34be797ab8bb80526367009495a7eb2118f.diff
LOG: [X86] Auto upgrade SSE/AVX PABS intrinsics to generic Intrinsic::abs
Minor followup to D87101, we were expanding this to a neg+icmp+select pattern like we were in CGBuiltin
Added:
Modified:
llvm/lib/IR/AutoUpgrade.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 369dc5089572..5ec3eb85d99d 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -1375,16 +1375,12 @@ static Value *UpgradeMaskedLoad(IRBuilder<> &Builder,
}
static Value *upgradeAbs(IRBuilder<> &Builder, CallInst &CI) {
+ Type *Ty = CI.getType();
Value *Op0 = CI.getArgOperand(0);
- llvm::Type *Ty = Op0->getType();
- Value *Zero = llvm::Constant::getNullValue(Ty);
- Value *Cmp = Builder.CreateICmp(ICmpInst::ICMP_SGT, Op0, Zero);
- Value *Neg = Builder.CreateNeg(Op0);
- Value *Res = Builder.CreateSelect(Cmp, Op0, Neg);
-
+ Function *F = Intrinsic::getDeclaration(CI.getModule(), Intrinsic::abs, Ty);
+ Value *Res = Builder.CreateCall(F, {Op0, Builder.getInt1(false)});
if (CI.getNumArgOperands() == 3)
- Res = EmitX86Select(Builder,CI.getArgOperand(2), Res, CI.getArgOperand(1));
-
+ Res = EmitX86Select(Builder, CI.getArgOperand(2), Res, CI.getArgOperand(1));
return Res;
}
More information about the llvm-commits
mailing list