reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced

References

lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp
  748   Builder.setFastMathFlags(FMF);
  757   Type *I32Ty = Builder.getInt32Ty();
  758   Type *F32Ty = Builder.getFloatTy();
  762       Num = Builder.CreateSExt(Num, I32Ty);
  763       Den = Builder.CreateSExt(Den, I32Ty);
  765       Num = Builder.CreateZExt(Num, I32Ty);
  766       Den = Builder.CreateZExt(Den, I32Ty);
  770   if (Value *Res = expandDivRem24(Builder, I, Num, Den, IsDiv, IsSigned)) {
  771     Res = Builder.CreateTrunc(Res, Ty);
  775   ConstantInt *Zero = Builder.getInt32(0);
  776   ConstantInt *One = Builder.getInt32(1);
  777   ConstantInt *MinusOne = Builder.getInt32(~0);
  781     ConstantInt *K31 = Builder.getInt32(31);
  782     Value *LHSign = Builder.CreateAShr(Num, K31);
  783     Value *RHSign = Builder.CreateAShr(Den, K31);
  785     Sign = IsDiv ? Builder.CreateXor(LHSign, RHSign) : LHSign;
  787     Num = Builder.CreateAdd(Num, LHSign);
  788     Den = Builder.CreateAdd(Den, RHSign);
  790     Num = Builder.CreateXor(Num, LHSign);
  791     Den = Builder.CreateXor(Den, RHSign);
  796   Value *DEN_F32 = Builder.CreateUIToFP(Den, F32Ty);
  797   Value *RCP_F32 = Builder.CreateFDiv(ConstantFP::get(F32Ty, 1.0), DEN_F32);
  799   Value *RCP_SCALE = Builder.CreateFMul(RCP_F32, UINT_MAX_PLUS_1);
  800   Value *RCP = Builder.CreateFPToUI(RCP_SCALE, I32Ty);
  804   std::tie(RCP_LO, RCP_HI) = getMul64(Builder, RCP, Den);
  807   Value *NEG_RCP_LO = Builder.CreateNeg(RCP_LO);
  810   Value *RCP_HI_0_CC = Builder.CreateICmpEQ(RCP_HI, Zero);
  811   Value *ABS_RCP_LO = Builder.CreateSelect(RCP_HI_0_CC, NEG_RCP_LO, RCP_LO);
  815   Value *E = getMulHu(Builder, ABS_RCP_LO, RCP);
  818   Value *RCP_A_E = Builder.CreateAdd(RCP, E);
  821   Value *RCP_S_E = Builder.CreateSub(RCP, E);
  824   Value *Tmp0 = Builder.CreateSelect(RCP_HI_0_CC, RCP_A_E, RCP_S_E);
  827   Value *Quotient = getMulHu(Builder, Tmp0, Num);
  830   Value *Num_S_Remainder = Builder.CreateMul(Quotient, Den);
  833   Value *Remainder = Builder.CreateSub(Num, Num_S_Remainder);
  836   Value *Rem_GE_Den_CC = Builder.CreateICmpUGE(Remainder, Den);
  837   Value *Remainder_GE_Den = Builder.CreateSelect(Rem_GE_Den_CC, MinusOne, Zero);
  840   Value *Num_GE_Num_S_Rem_CC = Builder.CreateICmpUGE(Num, Num_S_Remainder);
  841   Value *Remainder_GE_Zero = Builder.CreateSelect(Num_GE_Num_S_Rem_CC,
  845   Value *Tmp1 = Builder.CreateAnd(Remainder_GE_Den, Remainder_GE_Zero);
  846   Value *Tmp1_0_CC = Builder.CreateICmpEQ(Tmp1, Zero);
  851     Value *Quotient_A_One = Builder.CreateAdd(Quotient, One);
  854     Value *Quotient_S_One = Builder.CreateSub(Quotient, One);
  857     Value *Div = Builder.CreateSelect(Tmp1_0_CC, Quotient, Quotient_A_One);
  860     Res = Builder.CreateSelect(Num_GE_Num_S_Rem_CC, Div, Quotient_S_One);
  863     Value *Remainder_S_Den = Builder.CreateSub(Remainder, Den);
  866     Value *Remainder_A_Den = Builder.CreateAdd(Remainder, Den);
  869     Value *Rem = Builder.CreateSelect(Tmp1_0_CC, Remainder, Remainder_S_Den);
  872     Res = Builder.CreateSelect(Num_GE_Num_S_Rem_CC, Rem, Remainder_A_Den);
  876     Res = Builder.CreateXor(Res, Sign);
  877     Res = Builder.CreateSub(Res, Sign);
  880   Res = Builder.CreateTrunc(Res, Ty);