Remove unused intrinsic functions

This commit is contained in:
Magnus Norddahl 2017-01-09 11:25:21 +01:00
parent 407204ee2c
commit b91e88a9a6
8 changed files with 4 additions and 198 deletions

View file

@ -54,18 +54,6 @@ llvm::Type *SSAFloat::llvm_type()
return llvm::Type::getFloatTy(SSAScope::context());
}
SSAFloat SSAFloat::sqrt(SSAFloat f)
{
std::vector<llvm::Type *> params;
params.push_back(SSAFloat::llvm_type());
return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::sqrt, params), f.v, SSAScope::hint()));
}
SSAFloat SSAFloat::fastsqrt(SSAFloat f)
{
return f * rsqrt(f);
}
SSAFloat SSAFloat::rsqrt(SSAFloat f)
{
llvm::Value *f_ss = SSAScope::builder().CreateInsertElement(llvm::UndefValue::get(SSAVec4f::llvm_type()), f.v, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)0)));
@ -73,75 +61,6 @@ SSAFloat SSAFloat::rsqrt(SSAFloat f)
return SSAFloat::from_llvm(SSAScope::builder().CreateExtractElement(f_ss, SSAInt(0).v, SSAScope::hint()));
}
SSAFloat SSAFloat::sin(SSAFloat val)
{
std::vector<llvm::Type *> params;
params.push_back(SSAFloat::llvm_type());
return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::sin, params), val.v, SSAScope::hint()));
}
SSAFloat SSAFloat::cos(SSAFloat val)
{
std::vector<llvm::Type *> params;
params.push_back(SSAFloat::llvm_type());
return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::cos, params), val.v, SSAScope::hint()));
}
SSAFloat SSAFloat::pow(SSAFloat val, SSAFloat power)
{
std::vector<llvm::Type *> params;
params.push_back(SSAFloat::llvm_type());
//params.push_back(SSAFloat::llvm_type());
std::vector<llvm::Value*> args;
args.push_back(val.v);
args.push_back(power.v);
return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::pow, params), args, SSAScope::hint()));
}
SSAFloat SSAFloat::exp(SSAFloat val)
{
std::vector<llvm::Type *> params;
params.push_back(SSAFloat::llvm_type());
return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::exp, params), val.v, SSAScope::hint()));
}
SSAFloat SSAFloat::log(SSAFloat val)
{
std::vector<llvm::Type *> params;
params.push_back(SSAFloat::llvm_type());
return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::log, params), val.v, SSAScope::hint()));
}
SSAFloat SSAFloat::fma(SSAFloat a, SSAFloat b, SSAFloat c)
{
std::vector<llvm::Type *> params;
params.push_back(SSAFloat::llvm_type());
//params.push_back(SSAFloat::llvm_type());
//params.push_back(SSAFloat::llvm_type());
std::vector<llvm::Value*> args;
args.push_back(a.v);
args.push_back(b.v);
args.push_back(c.v);
return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::fma, params), args, SSAScope::hint()));
}
/* This intrinsic isn't always available..
SSAFloat SSAFloat::round(SSAFloat val)
{
std::vector<llvm::Type *> params;
params.push_back(SSAFloat::llvm_type());
return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::round, params), val.v, SSAScope::hint()));
}
*/
SSAFloat SSAFloat::floor(SSAFloat val)
{
std::vector<llvm::Type *> params;
params.push_back(SSAFloat::llvm_type());
return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::floor, params), val.v, SSAScope::hint()));
}
SSAFloat SSAFloat::MIN(SSAFloat a, SSAFloat b)
{
return SSAFloat::from_llvm(SSAScope::builder().CreateSelect((a < b).v, a.v, b.v, SSAScope::hint()));

View file

@ -36,17 +36,7 @@ public:
explicit SSAFloat(llvm::Value *v);
static SSAFloat from_llvm(llvm::Value *v) { return SSAFloat(v); }
static llvm::Type *llvm_type();
static SSAFloat sqrt(SSAFloat f);
static SSAFloat fastsqrt(SSAFloat f);
static SSAFloat rsqrt(SSAFloat f);
static SSAFloat sin(SSAFloat val);
static SSAFloat cos(SSAFloat val);
static SSAFloat pow(SSAFloat val, SSAFloat power);
static SSAFloat exp(SSAFloat val);
static SSAFloat log(SSAFloat val);
static SSAFloat fma(SSAFloat a, SSAFloat b, SSAFloat c);
//static SSAFloat round(SSAFloat val);
static SSAFloat floor(SSAFloat val);
static SSAFloat MIN(SSAFloat a, SSAFloat b);
static SSAFloat MAX(SSAFloat a, SSAFloat b);
static SSAFloat clamp(SSAFloat a, SSAFloat b, SSAFloat c);

View file

@ -111,71 +111,6 @@ SSAVec4f SSAVec4f::bitcast(SSAVec4i i32)
return SSAVec4i::from_llvm(SSAScope::builder().CreateBitCast(i32.v, llvm_type(), SSAScope::hint()));
}
SSAVec4f SSAVec4f::sqrt(SSAVec4f f)
{
std::vector<llvm::Type *> params;
params.push_back(SSAVec4f::llvm_type());
return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::sqrt, params), f.v, SSAScope::hint()));
//return SSAVec4f::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse_sqrt_ps), f.v, SSAScope::hint()));
}
SSAVec4f SSAVec4f::rcp(SSAVec4f f)
{
return SSAVec4f::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse_rcp_ps), f.v, SSAScope::hint()));
}
SSAVec4f SSAVec4f::sin(SSAVec4f val)
{
std::vector<llvm::Type *> params;
params.push_back(SSAVec4f::llvm_type());
return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::sin, params), val.v, SSAScope::hint()));
}
SSAVec4f SSAVec4f::cos(SSAVec4f val)
{
std::vector<llvm::Type *> params;
params.push_back(SSAVec4f::llvm_type());
return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::cos, params), val.v, SSAScope::hint()));
}
SSAVec4f SSAVec4f::pow(SSAVec4f val, SSAVec4f power)
{
std::vector<llvm::Type *> params;
params.push_back(SSAVec4f::llvm_type());
//params.push_back(SSAVec4f::llvm_type());
std::vector<llvm::Value*> args;
args.push_back(val.v);
args.push_back(power.v);
return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::pow, params), args, SSAScope::hint()));
}
SSAVec4f SSAVec4f::exp(SSAVec4f val)
{
std::vector<llvm::Type *> params;
params.push_back(SSAVec4f::llvm_type());
return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::exp, params), val.v, SSAScope::hint()));
}
SSAVec4f SSAVec4f::log(SSAVec4f val)
{
std::vector<llvm::Type *> params;
params.push_back(SSAVec4f::llvm_type());
return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::log, params), val.v, SSAScope::hint()));
}
SSAVec4f SSAVec4f::fma(SSAVec4f a, SSAVec4f b, SSAVec4f c)
{
std::vector<llvm::Type *> params;
params.push_back(SSAVec4f::llvm_type());
//params.push_back(SSAVec4f::llvm_type());
//params.push_back(SSAVec4f::llvm_type());
std::vector<llvm::Value*> args;
args.push_back(a.v);
args.push_back(b.v);
args.push_back(c.v);
return SSAFloat::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::fma, params), args, SSAScope::hint()));
}
void SSAVec4f::transpose(SSAVec4f &row0, SSAVec4f &row1, SSAVec4f &row2, SSAVec4f &row3)
{
SSAVec4f tmp0 = shuffle(row0, row1, 0x44);//_MM_SHUFFLE(1,0,1,0));

View file

@ -43,14 +43,6 @@ public:
SSAFloat operator[](int index) const;
static SSAVec4f insert_element(SSAVec4f vec4f, SSAFloat value, int index);
static SSAVec4f bitcast(SSAVec4i i32);
static SSAVec4f sqrt(SSAVec4f f);
static SSAVec4f rcp(SSAVec4f f);
static SSAVec4f sin(SSAVec4f val);
static SSAVec4f cos(SSAVec4f val);
static SSAVec4f pow(SSAVec4f val, SSAVec4f power);
static SSAVec4f exp(SSAVec4f val);
static SSAVec4f log(SSAVec4f val);
static SSAVec4f fma(SSAVec4f a, SSAVec4f b, SSAVec4f c);
static void transpose(SSAVec4f &row0, SSAVec4f &row1, SSAVec4f &row2, SSAVec4f &row3);
static SSAVec4f shuffle(const SSAVec4f &f0, int index0, int index1, int index2, int index3);
static SSAVec4f shuffle(const SSAVec4f &f0, const SSAVec4f &f1, int index0, int index1, int index2, int index3);

View file

@ -89,11 +89,13 @@ SSAVec4i::SSAVec4i(SSAInt i0, SSAInt i1, SSAInt i2, SSAInt i3)
#endif
}
/*
SSAVec4i::SSAVec4i(SSAVec4f f32)
: v(0)
{
v = SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_cvttps2dq), f32.v, SSAScope::hint());
}
*/
SSAInt SSAVec4i::operator[](SSAInt index) const
{
@ -198,11 +200,6 @@ SSAVec4i SSAVec4i::combinelo(SSAVec8s a, SSAVec8s b)
return SSAVec4i::bitcast(SSAVec8s::shuffle(a, b, 0, 8+0, 1, 8+1, 2, 8+2, 3, 8+3)); // _mm_unpacklo_epi16
}
SSAVec4i SSAVec4i::sqrt(SSAVec4i f)
{
return SSAVec4i::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_sqrt_pd), f.v, SSAScope::hint()));
}
SSAVec4i operator+(const SSAVec4i &a, const SSAVec4i &b)
{
return SSAVec4i::from_llvm(SSAScope::builder().CreateAdd(a.v, b.v, SSAScope::hint()));
@ -265,9 +262,7 @@ SSAVec4i operator/(const SSAVec4i &a, int b)
SSAVec4i operator<<(const SSAVec4i &a, int bits)
{
//return SSAScope::builder().CreateShl(a.v, bits);
llvm::Value *values[2] = { a.v, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)bits)) };
return SSAVec4i::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_pslli_d), values, SSAScope::hint()));
return SSAInt::from_llvm(SSAScope::builder().CreateShl(a.v, bits, SSAScope::hint()));
}
SSAVec4i operator>>(const SSAVec4i &a, int bits)

View file

@ -55,7 +55,6 @@ public:
static void extend(SSAVec16ub a, SSAVec4i &out0, SSAVec4i &out1, SSAVec4i &out2, SSAVec4i &out3);
static SSAVec4i combinehi(SSAVec8s v0, SSAVec8s v1);
static SSAVec4i combinelo(SSAVec8s v0, SSAVec8s v1);
static SSAVec4i sqrt(SSAVec4i f);
static SSAVec4i from_llvm(llvm::Value *v) { return SSAVec4i(v); }
static llvm::Type *llvm_type();

View file

@ -106,26 +106,6 @@ SSAVec8s SSAVec8s::extendlo(SSAVec16ub a)
return SSAVec8s::bitcast(SSAVec16ub::shuffle(a, SSAVec16ub((unsigned char)0), 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7)); // _mm_unpacklo_epi8
}
/*
SSAVec8s SSAVec8s::min_sse2(SSAVec8s a, SSAVec8s b)
{
llvm::Value *values[2] = { a.v, b.v };
return SSAVec8s::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_pmins_w), values, SSAScope::hint()));
}
SSAVec8s SSAVec8s::max_sse2(SSAVec8s a, SSAVec8s b)
{
llvm::Value *values[2] = { a.v, b.v };
return SSAVec8s::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_pmaxs_w), values, SSAScope::hint()));
}
*/
SSAVec8s SSAVec8s::mulhi(SSAVec8s a, SSAVec8s b)
{
llvm::Value *values[2] = { a.v, b.v };
return SSAVec8s::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_pmulh_w), values, SSAScope::hint()));
}
SSAVec8s operator+(const SSAVec8s &a, const SSAVec8s &b)
{
return SSAVec8s::from_llvm(SSAScope::builder().CreateAdd(a.v, b.v, SSAScope::hint()));
@ -188,9 +168,7 @@ SSAVec8s operator/(const SSAVec8s &a, short b)
SSAVec8s operator<<(const SSAVec8s &a, int bits)
{
//return SSAScope::builder().CreateShl(a.v, bits);
llvm::Value *values[2] = { a.v, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)bits)) };
return SSAVec8s::from_llvm(SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_pslli_d), values, SSAScope::hint()));
return SSAVec8s::from_llvm(SSAScope::builder().CreateShl(a.v, bits, SSAScope::hint()));
}
SSAVec8s operator>>(const SSAVec8s &a, int bits)

View file

@ -41,8 +41,6 @@ public:
static SSAVec8s shuffle(const SSAVec8s &i0, const SSAVec8s &i1, int index0, int index1, int index2, int index3, int index4, int index5, int index6, int index7);
static SSAVec8s extendhi(SSAVec16ub a);
static SSAVec8s extendlo(SSAVec16ub a);
//static SSAVec8s min_sse2(SSAVec8s a, SSAVec8s b);
//static SSAVec8s max_sse2(SSAVec8s a, SSAVec8s b);
static SSAVec8s mulhi(SSAVec8s a, SSAVec8s b);
static SSAVec8s from_llvm(llvm::Value *v) { return SSAVec8s(v); }
static llvm::Type *llvm_type();