[llvm] [AMDGPU] Fold llvm.amdgcn.cvt.pkrtz when either operand is fpext (PR #108237)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 12 01:54:14 PDT 2024
================
@@ -643,27 +643,38 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
break;
}
case Intrinsic::amdgcn_cvt_pkrtz: {
- Value *Src0 = II.getArgOperand(0);
- Value *Src1 = II.getArgOperand(1);
- if (const ConstantFP *C0 = dyn_cast<ConstantFP>(Src0)) {
- if (const ConstantFP *C1 = dyn_cast<ConstantFP>(Src1)) {
- const fltSemantics &HalfSem =
- II.getType()->getScalarType()->getFltSemantics();
+ auto foldFPTruncToF16RTZ = [](Value *Arg) -> Value * {
+ Type *HalfTy = Type::getHalfTy(Arg->getContext());
+
+ if (isa<PoisonValue>(Arg))
+ return PoisonValue::get(HalfTy);
+ if (isa<UndefValue>(Arg))
+ return UndefValue::get(HalfTy);
----------------
jayfoad wrote:
I was following [ConstantFoldCastInstruction](https://github.com/llvm/llvm-project/blob/7294396a0878a6bd179fac9aa5c3743832c799f4/llvm/lib/IR/ConstantFold.cpp#L142) which will fold (fptrunc undef) to undef.
https://github.com/llvm/llvm-project/pull/108237
More information about the llvm-commits
mailing list