@@ -49,6 +49,7 @@ static bool isIntrinsicExpansion(Function &F) {
49
49
case Intrinsic::log:
50
50
case Intrinsic::log10:
51
51
case Intrinsic::pow:
52
+ case Intrinsic::powi:
52
53
case Intrinsic::dx_all:
53
54
case Intrinsic::dx_any:
54
55
case Intrinsic::dx_cross:
@@ -251,7 +252,7 @@ static Value *expandExpIntrinsic(CallInst *Orig) {
251
252
}
252
253
253
254
static Value *expandAnyOrAllIntrinsic (CallInst *Orig,
254
- Intrinsic::ID intrinsicId ) {
255
+ Intrinsic::ID IntrinsicId ) {
255
256
Value *X = Orig->getOperand (0 );
256
257
IRBuilder<> Builder (Orig);
257
258
Type *Ty = X->getType ();
@@ -285,7 +286,7 @@ static Value *expandAnyOrAllIntrinsic(CallInst *Orig,
285
286
Result = Builder.CreateExtractElement (Cond, (uint64_t )0 );
286
287
for (unsigned I = 1 ; I < XVec->getNumElements (); I++) {
287
288
Value *Elt = Builder.CreateExtractElement (Cond, I);
288
- Result = ApplyOp (intrinsicId , Result, Elt);
289
+ Result = ApplyOp (IntrinsicId , Result, Elt);
289
290
}
290
291
}
291
292
return Result;
@@ -410,13 +411,16 @@ static Value *expandAtan2Intrinsic(CallInst *Orig) {
410
411
return Result;
411
412
}
412
413
413
- static Value *expandPowIntrinsic (CallInst *Orig) {
414
+ static Value *expandPowIntrinsic (CallInst *Orig, Intrinsic::ID IntrinsicId ) {
414
415
415
416
Value *X = Orig->getOperand (0 );
416
417
Value *Y = Orig->getOperand (1 );
417
418
Type *Ty = X->getType ();
418
419
IRBuilder<> Builder (Orig);
419
420
421
+ if (IntrinsicId == Intrinsic::powi)
422
+ Y = Builder.CreateSIToFP (Y, Ty);
423
+
420
424
auto *Log2Call =
421
425
Builder.CreateIntrinsic (Ty, Intrinsic::log2, {X}, nullptr , " elt.log2" );
422
426
auto *Mul = Builder.CreateFMul (Log2Call, Y);
@@ -542,7 +546,8 @@ static bool expandIntrinsic(Function &F, CallInst *Orig) {
542
546
Result = expandLog10Intrinsic (Orig);
543
547
break ;
544
548
case Intrinsic::pow:
545
- Result = expandPowIntrinsic (Orig);
549
+ case Intrinsic::powi:
550
+ Result = expandPowIntrinsic (Orig, IntrinsicId);
546
551
break ;
547
552
case Intrinsic::dx_all:
548
553
case Intrinsic::dx_any:
0 commit comments