[llvm] [GlobalISel] Support fixed vectors in constant-fold combines. (PR #220876)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 7 23:43:37 PDT 2026
================
@@ -1043,22 +1047,21 @@ llvm::ConstantFoldUnaryFPOp(unsigned Opcode, LLT DstTy, Register Src,
APFloat::rmNearestTiesToEven, &Unused);
return Result;
case TargetOpcode::G_FSQRT:
- Result.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven,
- &Unused);
- Result = APFloat(std::sqrt(Result.convertToDouble()));
- break;
- case TargetOpcode::G_FLOG2:
- Result.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven,
- &Unused);
- Result = APFloat(std::log2(Result.convertToDouble()));
- break;
+ case TargetOpcode::G_FLOG2: {
+ Type *Ty =
+ Type::getFloatingPointTy(MRI.getMF().getFunction().getContext(),
+ getFltSemanticForLLT(DstEltTy));
+ Constant *C = ConstantFoldFP(Opcode == TargetOpcode::G_FSQRT
+ ? static_cast<double (*)(double)>(sqrt)
+ : static_cast<double (*)(double)>(log2),
----------------
arsenm wrote:
Why are the casts needed?
https://github.com/llvm/llvm-project/pull/220876
More information about the llvm-commits
mailing list