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