How to migrate x86_sse2_psrl_dq after LLVM v3.8?

Hi LLVM developers,

After Remove int_x86_sse2_psll_dq_bs and int_x86_sse2_psrl_dq_bs intrinsics. The builtins aren't used by clang. rG4e0700f3654f there was no Intrinsic::x86_sse2_psrl_dq any more, then how to migrate:

Function *F =
             Intrinsic::getDeclaration(TheModule, Intrinsic::x86_sse2_psrl_dq);
         Result =
             Builder.CreateCall(F, ArrayRef<Value *>(&Ops[0], 2), "palignr");

And clang v3.9 migrated X86::BI__builtin_ia32_palignr128 like this clang/CGBuiltin.cpp at master · llvm-mirror/clang · GitHub just ignored the if (shiftVal < 32) condition? clang/CGBuiltin.cpp at release_33 · llvm-mirror/clang · GitHub

Please give me some hint, thanks a lot!

We should still parse IR containing that intrinsic and turn into something equivalent. You can see what that looks like by running it through the opt binary without running any passes.

If you’re trying to generate IR and you used to generate that intrinsic, you’ll need to generate an equivalent shufflevector instruction. You can find code for that in AutoUpgrade.cpp

Hi Craig,

Thanks for your kind response!

We should still parse IR containing that intrinsic and turn into something equivalent. You can see what that looks like by running it through the opt binary without running any passes.

I am migrating dragonegg https://reviews.llvm.org/D35667 I will test it without running any PASS.

If you're trying to generate IR and you used to generate that intrinsic, you'll need to generate an equivalent shufflevector instruction. You can find code for that in AutoUpgrade.cpp

I just grep sse2.psrl.dq in lib/IR/AutoUpgrade.cpp, there is UpgradeX86PSRLDQIntrinsics for x86.sse2.psrl.dq, and emit a shuffle to move the bytes if (Shift < 16), else just return the zero vector Constant::getNullValue https://github.com/llvm-mirror/llvm/blob/master/lib/IR/AutoUpgrade.cpp#L639

so could I migrate dragonegg for the if (ShiftVal < 32) condition like this? https://github.com/xiangzhai/dragonegg/blob/gcc-6_3-branch/src/x86/Target.cpp#L904