[llvm] SimplifyLibCalls: Emit vector ldexp intrinsics in exp2->ldexp combine (PR #92219)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed May 15 00:12:47 PDT 2024


================
@@ -2000,11 +2000,16 @@ static Value *getIntToFPVal(Value *I2F, IRBuilderBase &B, unsigned DstWidth) {
     Value *Op = cast<Instruction>(I2F)->getOperand(0);
     // Make sure that the exponent fits inside an "int" of size DstWidth,
     // thus avoiding any range issues that FP has not.
-    unsigned BitWidth = Op->getType()->getPrimitiveSizeInBits();
-    if (BitWidth < DstWidth ||
-        (BitWidth == DstWidth && isa<SIToFPInst>(I2F)))
-      return isa<SIToFPInst>(I2F) ? B.CreateSExt(Op, B.getIntNTy(DstWidth))
-                                  : B.CreateZExt(Op, B.getIntNTy(DstWidth));
+    unsigned BitWidth =
+        Op->getType()->getScalarType()->getPrimitiveSizeInBits();
+    if (BitWidth < DstWidth || (BitWidth == DstWidth && isa<SIToFPInst>(I2F))) {
+      Type *IntTy = B.getIntNTy(DstWidth);
+      if (VectorType *VT = dyn_cast<VectorType>(I2F->getType()))
+        IntTy = VectorType::get(IntTy, VT->getElementCount());
----------------
nikic wrote:

`Type::getWithNewBitWidth()`?

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


More information about the llvm-commits mailing list