@@ -49,6 +49,7 @@ static bool isIntrinsicExpansion(Function &F) {
4949 case Intrinsic::log:
5050 case Intrinsic::log10:
5151 case Intrinsic::pow:
52+ case Intrinsic::powi:
5253 case Intrinsic::dx_all:
5354 case Intrinsic::dx_any:
5455 case Intrinsic::dx_cross:
@@ -251,7 +252,7 @@ static Value *expandExpIntrinsic(CallInst *Orig) {
251252}
252253
253254static Value *expandAnyOrAllIntrinsic (CallInst *Orig,
254- Intrinsic::ID intrinsicId ) {
255+ Intrinsic::ID IntrinsicId ) {
255256 Value *X = Orig->getOperand (0 );
256257 IRBuilder<> Builder (Orig);
257258 Type *Ty = X->getType ();
@@ -285,7 +286,7 @@ static Value *expandAnyOrAllIntrinsic(CallInst *Orig,
285286 Result = Builder.CreateExtractElement (Cond, (uint64_t )0 );
286287 for (unsigned I = 1 ; I < XVec->getNumElements (); I++) {
287288 Value *Elt = Builder.CreateExtractElement (Cond, I);
288- Result = ApplyOp (intrinsicId , Result, Elt);
289+ Result = ApplyOp (IntrinsicId , Result, Elt);
289290 }
290291 }
291292 return Result;
@@ -410,13 +411,16 @@ static Value *expandAtan2Intrinsic(CallInst *Orig) {
410411 return Result;
411412}
412413
413- static Value *expandPowIntrinsic (CallInst *Orig) {
414+ static Value *expandPowIntrinsic (CallInst *Orig, Intrinsic::ID IntrinsicId ) {
414415
415416 Value *X = Orig->getOperand (0 );
416417 Value *Y = Orig->getOperand (1 );
417418 Type *Ty = X->getType ();
418419 IRBuilder<> Builder (Orig);
419420
421+ if (IntrinsicId == Intrinsic::powi)
422+ Y = Builder.CreateSIToFP (Y, Ty);
423+
420424 auto *Log2Call =
421425 Builder.CreateIntrinsic (Ty, Intrinsic::log2, {X}, nullptr , " elt.log2" );
422426 auto *Mul = Builder.CreateFMul (Log2Call, Y);
@@ -542,7 +546,8 @@ static bool expandIntrinsic(Function &F, CallInst *Orig) {
542546 Result = expandLog10Intrinsic (Orig);
543547 break ;
544548 case Intrinsic::pow:
545- Result = expandPowIntrinsic (Orig);
549+ case Intrinsic::powi:
550+ Result = expandPowIntrinsic (Orig, IntrinsicId);
546551 break ;
547552 case Intrinsic::dx_all:
548553 case Intrinsic::dx_any:
0 commit comments