[llvm] [GlobalISel] Support fixed vectors in constant-fold combines. (PR #220876)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 8 04:06:47 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:
Isn't that just the difference between math.h and cmath? What if you qualify both with `::sqrt`
https://github.com/llvm/llvm-project/pull/220876
More information about the llvm-commits
mailing list