|
26 | 26 | #include "llvm/IR/Dominators.h" |
27 | 27 | #include "llvm/IR/IRBuilder.h" |
28 | 28 | #include "llvm/IR/InstVisitor.h" |
29 | | -#include "llvm/IR/Intrinsics.h" |
30 | 29 | #include "llvm/IR/IntrinsicsAMDGPU.h" |
31 | 30 | #include "llvm/IR/PatternMatch.h" |
32 | 31 | #include "llvm/IR/ValueHandle.h" |
33 | 32 | #include "llvm/InitializePasses.h" |
34 | 33 | #include "llvm/Pass.h" |
35 | 34 | #include "llvm/Support/KnownBits.h" |
36 | 35 | #include "llvm/Support/KnownFPClass.h" |
37 | | -#include "llvm/Transforms/Utils/BasicBlockUtils.h" |
38 | 36 | #include "llvm/Transforms/Utils/IntegerDivision.h" |
39 | 37 | #include "llvm/Transforms/Utils/Local.h" |
40 | | -#include <cstdint> |
41 | 38 |
|
42 | 39 | #define DEBUG_TYPE "amdgpu-codegenprepare" |
43 | 40 |
|
@@ -96,13 +93,6 @@ static cl::opt<bool> DisableFDivExpand( |
96 | 93 | cl::ReallyHidden, |
97 | 94 | cl::init(false)); |
98 | 95 |
|
99 | | -// Disable bitsin(typeof(x)) - popcnt(x) to s_bcnt0(x) transformation. |
100 | | -static cl::opt<bool> |
101 | | - DisableBcnt0("amdgpu-codegenprepare-disable-bcnt0", |
102 | | - cl::desc("Prevent transforming bitsin(typeof(x)) - " |
103 | | - "popcount(x) to bcnt0(x) in AMDGPUCodeGenPrepare"), |
104 | | - cl::ReallyHidden, cl::init(false)); |
105 | | - |
106 | 96 | class AMDGPUCodeGenPrepareImpl |
107 | 97 | : public InstVisitor<AMDGPUCodeGenPrepareImpl, bool> { |
108 | 98 | public: |
@@ -268,7 +258,6 @@ class AMDGPUCodeGenPrepareImpl |
268 | 258 | bool visitAddrSpaceCastInst(AddrSpaceCastInst &I); |
269 | 259 |
|
270 | 260 | bool visitIntrinsicInst(IntrinsicInst &I); |
271 | | - bool visitCtpop(IntrinsicInst &I); |
272 | 261 | bool visitFMinLike(IntrinsicInst &I); |
273 | 262 | bool visitSqrt(IntrinsicInst &I); |
274 | 263 | bool run(); |
@@ -1921,8 +1910,6 @@ bool AMDGPUCodeGenPrepareImpl::visitIntrinsicInst(IntrinsicInst &I) { |
1921 | 1910 | return visitFMinLike(I); |
1922 | 1911 | case Intrinsic::sqrt: |
1923 | 1912 | return visitSqrt(I); |
1924 | | - case Intrinsic::ctpop: |
1925 | | - return visitCtpop(I); |
1926 | 1913 | default: |
1927 | 1914 | return false; |
1928 | 1915 | } |
@@ -1990,34 +1977,6 @@ Value *AMDGPUCodeGenPrepareImpl::applyFractPat(IRBuilder<> &Builder, |
1990 | 1977 | return insertValues(Builder, FractArg->getType(), ResultVals); |
1991 | 1978 | } |
1992 | 1979 |
|
1993 | | -bool AMDGPUCodeGenPrepareImpl::visitCtpop(IntrinsicInst &I) { |
1994 | | - uint32_t BitWidth, DestinationWidth; |
1995 | | - if (!I.hasOneUse() || !I.getType()->isIntegerTy()) |
1996 | | - return false; |
1997 | | - |
1998 | | - BitWidth = I.getType()->getIntegerBitWidth(); |
1999 | | - if(!ST.hasBCNT(BitWidth)) |
2000 | | - return false; |
2001 | | - |
2002 | | - Instruction *MustBeSub = I.user_back(); |
2003 | | - if (!match(MustBeSub, m_Sub(m_SpecificInt(BitWidth), m_Specific(&I)))) |
2004 | | - return false; |
2005 | | - |
2006 | | - IRBuilder<> Builder(MustBeSub); |
2007 | | - Instruction *TransformedIns = |
2008 | | - Builder.CreateIntrinsic(BitWidth > 32 ? Intrinsic::amdgcn_bcnt64_lo |
2009 | | - : Intrinsic::amdgcn_bcnt32_lo, |
2010 | | - {}, {I.getArgOperand(0)}); |
2011 | | - |
2012 | | - DestinationWidth = MustBeSub->getType()->getIntegerBitWidth(); |
2013 | | - TransformedIns = cast<Instruction>(Builder.CreateZExtOrTrunc( |
2014 | | - TransformedIns, Type::getIntNTy(I.getContext(), DestinationWidth))); |
2015 | | - |
2016 | | - BasicBlock::iterator SubIt = MustBeSub->getIterator(); |
2017 | | - ReplaceInstWithValue(SubIt,TransformedIns); |
2018 | | - return true; |
2019 | | -} |
2020 | | - |
2021 | 1980 | bool AMDGPUCodeGenPrepareImpl::visitFMinLike(IntrinsicInst &I) { |
2022 | 1981 | Value *FractArg = matchFractPat(I); |
2023 | 1982 | if (!FractArg) |
|
0 commit comments