@@ -2813,6 +2813,7 @@ static bool interp__builtin_select(InterpState &S, CodePtr OpPC,
28132813 }
28142814 }
28152815 Dst.initializeAllElements ();
2816+
28162817 return true ;
28172818}
28182819
@@ -2821,20 +2822,19 @@ static bool interp__builtin_elementwise_fsh(InterpState &S, CodePtr OpPC,
28212822 unsigned BuiltinID) {
28222823 assert (Call->getNumArgs () == 3 );
28232824
2824- const QualType Arg1Type = Call->getArg (0 )->getType ();
2825- const QualType Arg2Type = Call->getArg (1 )->getType ();
2826- const QualType Arg3Type = Call->getArg (2 )->getType ();
2825+ const QualType & Arg1Type = Call->getArg (0 )->getType ();
2826+ const QualType & Arg2Type = Call->getArg (1 )->getType ();
2827+ const QualType & Arg3Type = Call->getArg (2 )->getType ();
28272828
28282829 // Non-vector integer types.
28292830 if (!Arg1Type->isVectorType ()) {
28302831 assert (!Arg2Type->isVectorType ());
28312832 assert (!Arg3Type->isVectorType ());
2832-
2833- APSInt Shift = popToAPSInt (
2833+ const APSInt &Shift = popToAPSInt (
28342834 S.Stk , *S.getContext ().classify (Call->getArg (2 )->getType ()));
2835- APSInt Lo = popToAPSInt (
2835+ const APSInt & Lo = popToAPSInt (
28362836 S.Stk , *S.getContext ().classify (Call->getArg (1 )->getType ()));
2837- APSInt Hi = popToAPSInt (
2837+ const APSInt & Hi = popToAPSInt (
28382838 S.Stk , *S.getContext ().classify (Call->getArg (0 )->getType ()));
28392839 APSInt Result;
28402840 if (BuiltinID == Builtin::BI__builtin_elementwise_fshl) {
@@ -2849,18 +2849,17 @@ static bool interp__builtin_elementwise_fsh(InterpState &S, CodePtr OpPC,
28492849 }
28502850
28512851 // Vector type.
2852- assert (Arg1Type->isVectorType () &&
2853- Arg2Type->isVectorType () &&
2852+ assert (Arg1Type->isVectorType () && Arg2Type->isVectorType () &&
28542853 Arg3Type->isVectorType ());
28552854
28562855 const VectorType *VecT = Arg1Type->castAs <VectorType>();
2857- PrimType ElemT = *S.getContext ().classify (VecT->getElementType ());
2856+ const PrimType & ElemT = *S.getContext ().classify (VecT->getElementType ());
28582857 unsigned NumElems = VecT->getNumElements ();
28592858
28602859 assert (VecT->getElementType () ==
2861- Arg2Type->castAs <VectorType>()->getElementType () &&
2860+ Arg2Type->castAs <VectorType>()->getElementType () &&
28622861 VecT->getElementType () ==
2863- Arg3Type->castAs <VectorType>()->getElementType ());
2862+ Arg3Type->castAs <VectorType>()->getElementType ());
28642863 assert (NumElems == Arg2Type->castAs <VectorType>()->getNumElements () &&
28652864 NumElems == Arg3Type->castAs <VectorType>()->getNumElements ());
28662865 assert (VecT->getElementType ()->isIntegralOrEnumerationType ());
@@ -2870,26 +2869,27 @@ static bool interp__builtin_elementwise_fsh(InterpState &S, CodePtr OpPC,
28702869 const Pointer &VecHi = S.Stk .pop <Pointer>();
28712870 const Pointer &Dst = S.Stk .peek <Pointer>();
28722871 for (unsigned I = 0 ; I != NumElems; ++I) {
2873- APSInt Hi;
2874- APSInt Lo;
2875- APSInt Shift;
2876- INT_TYPE_SWITCH_NO_BOOL (ElemT, {
2877- Hi = VecHi.elem <T>(I).toAPSInt ();
2878- Lo = VecLo.elem <T>(I).toAPSInt ();
2879- Shift = VecShift.elem <T>(I).toAPSInt ();
2880- });
2881- APSInt Result;
2882- if (BuiltinID == Builtin::BI__builtin_elementwise_fshl) {
2883- Result = APSInt (llvm::APIntOps::fshl (Hi, Lo, Shift), Hi.isUnsigned ());
2884- } else if (BuiltinID == Builtin::BI__builtin_elementwise_fshr) {
2885- Result = APSInt (llvm::APIntOps::fshr (Hi, Lo, Shift), Hi.isUnsigned ());
2886- } else {
2887- llvm_unreachable (" Wrong builtin ID" );
2888- }
2889- INT_TYPE_SWITCH_NO_BOOL (ElemT,
2890- { Dst.elem <T>(I) = static_cast <T>(Result); });
2872+ APSInt Hi;
2873+ APSInt Lo;
2874+ APSInt Shift;
2875+ INT_TYPE_SWITCH_NO_BOOL (ElemT, {
2876+ Hi = VecHi.elem <T>(I).toAPSInt ();
2877+ Lo = VecLo.elem <T>(I).toAPSInt ();
2878+ Shift = VecShift.elem <T>(I).toAPSInt ();
2879+ });
2880+ APSInt Result;
2881+ if (BuiltinID == Builtin::BI__builtin_elementwise_fshl) {
2882+ Result = APSInt (llvm::APIntOps::fshl (Hi, Lo, Shift), Hi.isUnsigned ());
2883+ } else if (BuiltinID == Builtin::BI__builtin_elementwise_fshr) {
2884+ Result = APSInt (llvm::APIntOps::fshr (Hi, Lo, Shift), Hi.isUnsigned ());
2885+ } else {
2886+ llvm_unreachable (" Wrong builtin ID" );
2887+ }
2888+ INT_TYPE_SWITCH_NO_BOOL (ElemT,
2889+ { Dst.elem <T>(I) = static_cast <T>(Result); });
28912890 }
28922891 Dst.initializeAllElements ();
2892+
28932893 return true ;
28942894}
28952895
0 commit comments