[llvm] [AMDGPU] Use std::optional in InstCombine of amdgcn_fmed3. NFC. (PR #108223)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 11 06:50:36 PDT 2024
================
@@ -353,23 +353,20 @@ bool GCNTTIImpl::canSimplifyLegacyMulToMul(const Instruction &I,
}
/// Match an fpext from half to float, or a constant we can convert.
-static bool matchFPExtFromF16(Value *Arg, Value *&FPExtSrc) {
- if (match(Arg, m_OneUse(m_FPExt(m_Value(FPExtSrc)))))
- return FPExtSrc->getType()->isHalfTy();
-
+static std::optional<Value *> matchFPExtFromF16(Value *Arg) {
+ Value *Src;
ConstantFP *CFP;
- if (match(Arg, m_ConstantFP(CFP))) {
+ if (match(Arg, m_OneUse(m_FPExt(m_Value(Src))))) {
+ if (Src->getType()->isHalfTy())
+ return Src;
+ } else if (match(Arg, m_ConstantFP(CFP))) {
bool LosesInfo;
APFloat Val(CFP->getValueAPF());
Val.convert(APFloat::IEEEhalf(), APFloat::rmNearestTiesToEven, &LosesInfo);
- if (LosesInfo)
- return false;
-
- FPExtSrc = ConstantFP::get(Type::getHalfTy(Arg->getContext()), Val);
- return true;
+ if (!LosesInfo)
+ return ConstantFP::get(Type::getHalfTy(Arg->getContext()), Val);
}
-
- return false;
+ return {};
----------------
jayfoad wrote:
Done
https://github.com/llvm/llvm-project/pull/108223
More information about the llvm-commits
mailing list