[llvm] [ConstantFold] Fix result type when folding powi.f16 (PR #98681)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 13 00:36:18 PDT 2024


================
@@ -2754,27 +2754,28 @@ static Constant *ConstantFoldIntrinsicCall2(Intrinsic::ID IntrinsicID, Type *Ty,
           ((Mask & fcPosInf) && Op1V.isPosInfinity());
         return ConstantInt::get(Ty, Result);
       }
+      case Intrinsic::powi: {
+        int exp = static_cast<int>(Op2C->getZExtValue());
----------------
nikic wrote:

```suggestion
        int Exp = static_cast<int>(Op2C->getZExtValue());
```
Though while you're here, maybe fix this as well? Surely this should be getSExtValue(), and we shouldn't cast away the top bits either?

https://github.com/llvm/llvm-project/pull/98681


More information about the llvm-commits mailing list