@@ -2549,7 +2549,7 @@ static bool interp__builtin_elementwise_maxmin(InterpState &S, CodePtr OpPC,
2549
2549
return true ;
2550
2550
}
2551
2551
2552
- static bool interp__builtin_ia32_pmadd (
2552
+ static bool interp__builtin_ia32_pmul (
2553
2553
InterpState &S, CodePtr OpPC, const CallExpr *Call,
2554
2554
llvm::function_ref<APInt(const APSInt &, const APSInt &, const APSInt &,
2555
2555
const APSInt &)>
@@ -2587,54 +2587,6 @@ static bool interp__builtin_ia32_pmadd(
2587
2587
return true ;
2588
2588
}
2589
2589
2590
- static bool interp__builtin_ia32_pmul (InterpState &S, CodePtr OpPC,
2591
- const CallExpr *Call,
2592
- unsigned BuiltinID) {
2593
- assert (Call->getArg (0 )->getType ()->isVectorType () &&
2594
- Call->getArg (1 )->getType ()->isVectorType ());
2595
- const Pointer &RHS = S.Stk .pop <Pointer>();
2596
- const Pointer &LHS = S.Stk .pop <Pointer>();
2597
- const Pointer &Dst = S.Stk .peek <Pointer>();
2598
-
2599
- const auto *VT = Call->getArg (0 )->getType ()->castAs <VectorType>();
2600
- PrimType ElemT = *S.getContext ().classify (VT->getElementType ());
2601
- unsigned SourceLen = VT->getNumElements ();
2602
-
2603
- PrimType DstElemT = *S.getContext ().classify (
2604
- Call->getType ()->castAs <VectorType>()->getElementType ());
2605
- unsigned DstElem = 0 ;
2606
- for (unsigned I = 0 ; I != SourceLen; I += 2 ) {
2607
- APSInt Elem1;
2608
- APSInt Elem2;
2609
- INT_TYPE_SWITCH_NO_BOOL (ElemT, {
2610
- Elem1 = LHS.elem <T>(I).toAPSInt ();
2611
- Elem2 = RHS.elem <T>(I).toAPSInt ();
2612
- });
2613
-
2614
- APSInt Result;
2615
- switch (BuiltinID) {
2616
- case clang::X86::BI__builtin_ia32_pmuludq128:
2617
- case clang::X86::BI__builtin_ia32_pmuludq256:
2618
- case clang::X86::BI__builtin_ia32_pmuludq512:
2619
- Result = APSInt (llvm::APIntOps::muluExtended (Elem1, Elem2),
2620
- /* IsUnsigned=*/ true );
2621
- break ;
2622
- case clang::X86::BI__builtin_ia32_pmuldq128:
2623
- case clang::X86::BI__builtin_ia32_pmuldq256:
2624
- case clang::X86::BI__builtin_ia32_pmuldq512:
2625
- Result = APSInt (llvm::APIntOps::mulsExtended (Elem1, Elem2),
2626
- /* IsUnsigned=*/ false );
2627
- break ;
2628
- }
2629
- INT_TYPE_SWITCH_NO_BOOL (DstElemT,
2630
- { Dst.elem <T>(DstElem) = static_cast <T>(Result); });
2631
- ++DstElem;
2632
- }
2633
-
2634
- Dst.initializeAllElements ();
2635
- return true ;
2636
- }
2637
-
2638
2590
static bool interp__builtin_elementwise_triop_fp (
2639
2591
InterpState &S, CodePtr OpPC, const CallExpr *Call,
2640
2592
llvm::function_ref<APFloat(const APFloat &, const APFloat &,
@@ -3512,7 +3464,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
3512
3464
case clang::X86::BI__builtin_ia32_pmaddubsw128:
3513
3465
case clang::X86::BI__builtin_ia32_pmaddubsw256:
3514
3466
case clang::X86::BI__builtin_ia32_pmaddubsw512:
3515
- return interp__builtin_ia32_pmadd (
3467
+ return interp__builtin_ia32_pmul (
3516
3468
S, OpPC, Call,
3517
3469
[](const APSInt &LoLHS, const APSInt &HiLHS, const APSInt &LoRHS,
3518
3470
const APSInt &HiRHS) {
@@ -3524,7 +3476,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
3524
3476
case clang::X86::BI__builtin_ia32_pmaddwd128:
3525
3477
case clang::X86::BI__builtin_ia32_pmaddwd256:
3526
3478
case clang::X86::BI__builtin_ia32_pmaddwd512:
3527
- return interp__builtin_ia32_pmadd (
3479
+ return interp__builtin_ia32_pmul (
3528
3480
S, OpPC, Call,
3529
3481
[](const APSInt &LoLHS, const APSInt &HiLHS, const APSInt &LoRHS,
3530
3482
const APSInt &HiRHS) {
@@ -3677,10 +3629,22 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
3677
3629
case clang::X86::BI__builtin_ia32_pmuldq128:
3678
3630
case clang::X86::BI__builtin_ia32_pmuldq256:
3679
3631
case clang::X86::BI__builtin_ia32_pmuldq512:
3632
+ return interp__builtin_ia32_pmul (
3633
+ S, OpPC, Call,
3634
+ [](const APSInt &LoLHS, const APSInt &HiLHS, const APSInt &LoRHS,
3635
+ const APSInt &HiRHS) {
3636
+ return llvm::APIntOps::mulsExtended (LoLHS, LoRHS);
3637
+ });
3638
+
3680
3639
case clang::X86::BI__builtin_ia32_pmuludq128:
3681
3640
case clang::X86::BI__builtin_ia32_pmuludq256:
3682
3641
case clang::X86::BI__builtin_ia32_pmuludq512:
3683
- return interp__builtin_ia32_pmul (S, OpPC, Call, BuiltinID);
3642
+ return interp__builtin_ia32_pmul (
3643
+ S, OpPC, Call,
3644
+ [](const APSInt &LoLHS, const APSInt &HiLHS, const APSInt &LoRHS,
3645
+ const APSInt &HiRHS) {
3646
+ return llvm::APIntOps::muluExtended (LoLHS, LoRHS);
3647
+ });
3684
3648
3685
3649
case Builtin::BI__builtin_elementwise_fma:
3686
3650
return interp__builtin_elementwise_triop_fp (
0 commit comments