| Index: lib/Transforms/InstCombine/InstCombineCalls.cpp
|
| ===================================================================
|
| --- lib/Transforms/InstCombine/InstCombineCalls.cpp (revision 138929)
|
| +++ lib/Transforms/InstCombine/InstCombineCalls.cpp (working copy)
|
| @@ -545,6 +545,7 @@
|
| }
|
| }
|
| break;
|
| +#if defined(TARGET_ENABLED_POWERPC)
|
| case Intrinsic::ppc_altivec_lvx:
|
| case Intrinsic::ppc_altivec_lvxl:
|
| // Turn PPC lvx -> load if the pointer is known aligned.
|
| @@ -564,6 +565,58 @@
|
| return new StoreInst(II->getArgOperand(0), Ptr);
|
| }
|
| break;
|
| + case Intrinsic::ppc_altivec_vperm:
|
| + // Turn vperm(V1,V2,mask) -> shuffle(V1,V2,mask) if mask is a constant.
|
| + if (ConstantVector *Mask = dyn_cast<ConstantVector>(II->getArgOperand(2))) {
|
| + assert(Mask->getNumOperands() == 16 && "Bad type for intrinsic!");
|
| +
|
| + // Check that all of the elements are integer constants or undefs.
|
| + bool AllEltsOk = true;
|
| + for (unsigned i = 0; i != 16; ++i) {
|
| + if (!isa<ConstantInt>(Mask->getOperand(i)) &&
|
| + !isa<UndefValue>(Mask->getOperand(i))) {
|
| + AllEltsOk = false;
|
| + break;
|
| + }
|
| + }
|
| +
|
| + if (AllEltsOk) {
|
| + // Cast the input vectors to byte vectors.
|
| + Value *Op0 = Builder->CreateBitCast(II->getArgOperand(0),
|
| + Mask->getType());
|
| + Value *Op1 = Builder->CreateBitCast(II->getArgOperand(1),
|
| + Mask->getType());
|
| + Value *Result = UndefValue::get(Op0->getType());
|
| +
|
| + // Only extract each element once.
|
| + Value *ExtractedElts[32];
|
| + memset(ExtractedElts, 0, sizeof(ExtractedElts));
|
| +
|
| + for (unsigned i = 0; i != 16; ++i) {
|
| + if (isa<UndefValue>(Mask->getOperand(i)))
|
| + continue;
|
| + unsigned Idx=cast<ConstantInt>(Mask->getOperand(i))->getZExtValue();
|
| + Idx &= 31; // Match the hardware behavior.
|
| +
|
| + if (ExtractedElts[Idx] == 0) {
|
| + ExtractedElts[Idx] =
|
| + Builder->CreateExtractElement(Idx < 16 ? Op0 : Op1,
|
| + ConstantInt::get(Type::getInt32Ty(II->getContext()),
|
| + Idx&15, false), "tmp");
|
| + }
|
| +
|
| + // Insert this value into the result vector.
|
| + Result = Builder->CreateInsertElement(Result, ExtractedElts[Idx],
|
| + ConstantInt::get(Type::getInt32Ty(II->getContext()),
|
| + i, false), "tmp");
|
| + }
|
| + return CastInst::Create(Instruction::BitCast, Result, CI.getType());
|
| + }
|
| + }
|
| + break;
|
| +#endif // TARGET_ENABLED_POWERPC
|
| +
|
| +#if defined(TARGET_ENABLED_X86)
|
| case Intrinsic::x86_sse_storeu_ps:
|
| case Intrinsic::x86_sse2_storeu_pd:
|
| case Intrinsic::x86_sse2_storeu_dq:
|
| @@ -598,7 +651,6 @@
|
| break;
|
| }
|
|
|
| -
|
| case Intrinsic::x86_sse41_pmovsxbw:
|
| case Intrinsic::x86_sse41_pmovsxwd:
|
| case Intrinsic::x86_sse41_pmovsxdq:
|
| @@ -619,57 +671,9 @@
|
| }
|
| break;
|
| }
|
| +#endif // TARGET_ENABLED_X86
|
|
|
| - case Intrinsic::ppc_altivec_vperm:
|
| - // Turn vperm(V1,V2,mask) -> shuffle(V1,V2,mask) if mask is a constant.
|
| - if (ConstantVector *Mask = dyn_cast<ConstantVector>(II->getArgOperand(2))) {
|
| - assert(Mask->getNumOperands() == 16 && "Bad type for intrinsic!");
|
| -
|
| - // Check that all of the elements are integer constants or undefs.
|
| - bool AllEltsOk = true;
|
| - for (unsigned i = 0; i != 16; ++i) {
|
| - if (!isa<ConstantInt>(Mask->getOperand(i)) &&
|
| - !isa<UndefValue>(Mask->getOperand(i))) {
|
| - AllEltsOk = false;
|
| - break;
|
| - }
|
| - }
|
| -
|
| - if (AllEltsOk) {
|
| - // Cast the input vectors to byte vectors.
|
| - Value *Op0 = Builder->CreateBitCast(II->getArgOperand(0),
|
| - Mask->getType());
|
| - Value *Op1 = Builder->CreateBitCast(II->getArgOperand(1),
|
| - Mask->getType());
|
| - Value *Result = UndefValue::get(Op0->getType());
|
| -
|
| - // Only extract each element once.
|
| - Value *ExtractedElts[32];
|
| - memset(ExtractedElts, 0, sizeof(ExtractedElts));
|
| -
|
| - for (unsigned i = 0; i != 16; ++i) {
|
| - if (isa<UndefValue>(Mask->getOperand(i)))
|
| - continue;
|
| - unsigned Idx=cast<ConstantInt>(Mask->getOperand(i))->getZExtValue();
|
| - Idx &= 31; // Match the hardware behavior.
|
| -
|
| - if (ExtractedElts[Idx] == 0) {
|
| - ExtractedElts[Idx] =
|
| - Builder->CreateExtractElement(Idx < 16 ? Op0 : Op1,
|
| - ConstantInt::get(Type::getInt32Ty(II->getContext()),
|
| - Idx&15, false), "tmp");
|
| - }
|
| -
|
| - // Insert this value into the result vector.
|
| - Result = Builder->CreateInsertElement(Result, ExtractedElts[Idx],
|
| - ConstantInt::get(Type::getInt32Ty(II->getContext()),
|
| - i, false), "tmp");
|
| - }
|
| - return CastInst::Create(Instruction::BitCast, Result, CI.getType());
|
| - }
|
| - }
|
| - break;
|
| -
|
| +#if defined(TARGET_ENABLED_ARM)
|
| case Intrinsic::arm_neon_vld1:
|
| case Intrinsic::arm_neon_vld2:
|
| case Intrinsic::arm_neon_vld3:
|
| @@ -695,6 +699,7 @@
|
| }
|
| break;
|
| }
|
| +#endif // TARGET_ENABLED_ARM
|
|
|
| case Intrinsic::stackrestore: {
|
| // If the save is right next to the restore, remove the restore. This can
|
| @@ -1315,4 +1320,3 @@
|
| CS.setCalledFunction(NewCallee);
|
| return CS.getInstruction();
|
| }
|
| -
|
|
|