@@ -624,34 +624,6 @@ static Value *insertValues(IRBuilder<> &Builder,
624
624
return NewVal;
625
625
}
626
626
627
- // Returns 24-bit or 48-bit (as per `NumBits` and `Size`) mul of `LHS` and
628
- // `RHS`. `NumBits` is the number of KnownBits of the result and `Size` is the
629
- // width of the original destination.
630
- static Value *getMul24 (IRBuilder<> &Builder, Value *LHS, Value *RHS,
631
- unsigned Size , unsigned NumBits, bool IsSigned) {
632
- if (Size <= 32 || NumBits <= 32 ) {
633
- Intrinsic::ID ID =
634
- IsSigned ? Intrinsic::amdgcn_mul_i24 : Intrinsic::amdgcn_mul_u24;
635
- return Builder.CreateIntrinsic (ID, {}, {LHS, RHS});
636
- }
637
-
638
- assert (NumBits <= 48 );
639
-
640
- Intrinsic::ID LoID =
641
- IsSigned ? Intrinsic::amdgcn_mul_i24 : Intrinsic::amdgcn_mul_u24;
642
- Intrinsic::ID HiID =
643
- IsSigned ? Intrinsic::amdgcn_mulhi_i24 : Intrinsic::amdgcn_mulhi_u24;
644
-
645
- Value *Lo = Builder.CreateIntrinsic (LoID, {}, {LHS, RHS});
646
- Value *Hi = Builder.CreateIntrinsic (HiID, {}, {LHS, RHS});
647
-
648
- IntegerType *I64Ty = Builder.getInt64Ty ();
649
- Lo = Builder.CreateZExtOrTrunc (Lo, I64Ty);
650
- Hi = Builder.CreateZExtOrTrunc (Hi, I64Ty);
651
-
652
- return Builder.CreateOr (Lo, Builder.CreateShl (Hi, 32 ));
653
- }
654
-
655
627
bool AMDGPUCodeGenPrepareImpl::replaceMulWithMul24 (BinaryOperator &I) const {
656
628
if (I.getOpcode () != Instruction::Mul)
657
629
return false ;
@@ -691,26 +663,20 @@ bool AMDGPUCodeGenPrepareImpl::replaceMulWithMul24(BinaryOperator &I) const {
691
663
extractValues (Builder, RHSVals, RHS);
692
664
693
665
IntegerType *I32Ty = Builder.getInt32Ty ();
694
- for (int I = 0 , E = LHSVals.size (); I != E; ++I) {
695
- Value *LHS, *RHS;
696
- if (IsSigned) {
697
- LHS = Builder.CreateSExtOrTrunc (LHSVals[I], I32Ty);
698
- RHS = Builder.CreateSExtOrTrunc (RHSVals[I], I32Ty);
699
- } else {
700
- LHS = Builder.CreateZExtOrTrunc (LHSVals[I], I32Ty);
701
- RHS = Builder.CreateZExtOrTrunc (RHSVals[I], I32Ty);
702
- }
666
+ IntegerType *IntrinTy = Size > 32 ? Builder.getInt64Ty () : I32Ty;
667
+ Type *DstTy = LHSVals[0 ]->getType ();
703
668
704
- Value *Result =
705
- getMul24 (Builder, LHS, RHS, Size , LHSBits + RHSBits, IsSigned);
706
-
707
- if (IsSigned) {
708
- ResultVals.push_back (
709
- Builder.CreateSExtOrTrunc (Result, LHSVals[I]->getType ()));
710
- } else {
711
- ResultVals.push_back (
712
- Builder.CreateZExtOrTrunc (Result, LHSVals[I]->getType ()));
713
- }
669
+ for (int I = 0 , E = LHSVals.size (); I != E; ++I) {
670
+ Value *LHS = IsSigned ? Builder.CreateSExtOrTrunc (LHSVals[I], I32Ty)
671
+ : Builder.CreateZExtOrTrunc (LHSVals[I], I32Ty);
672
+ Value *RHS = IsSigned ? Builder.CreateSExtOrTrunc (RHSVals[I], I32Ty)
673
+ : Builder.CreateZExtOrTrunc (RHSVals[I], I32Ty);
674
+ Intrinsic::ID ID =
675
+ IsSigned ? Intrinsic::amdgcn_mul_i24 : Intrinsic::amdgcn_mul_u24;
676
+ Value *Result = Builder.CreateIntrinsic (ID, {IntrinTy}, {LHS, RHS});
677
+ Result = IsSigned ? Builder.CreateSExtOrTrunc (Result, DstTy)
678
+ : Builder.CreateZExtOrTrunc (Result, DstTy);
679
+ ResultVals.push_back (Result);
714
680
}
715
681
716
682
Value *NewVal = insertValues (Builder, Ty, ResultVals);
0 commit comments