[llvm] [IRBuilder] Fold binary intrinsics (PR #80743)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 22 08:01:38 PST 2024
================
@@ -767,19 +767,21 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
// Checking for NaN before canonicalization provides better fidelity when
// mapping other operations onto fmed3 since the order of operands is
// unchanged.
- CallInst *NewCall = nullptr;
+ Value *V = nullptr;
if (match(Src0, PatternMatch::m_NaN()) || isa<UndefValue>(Src0)) {
- NewCall = IC.Builder.CreateMinNum(Src1, Src2);
+ V = IC.Builder.CreateMinNum(Src1, Src2);
} else if (match(Src1, PatternMatch::m_NaN()) || isa<UndefValue>(Src1)) {
- NewCall = IC.Builder.CreateMinNum(Src0, Src2);
+ V = IC.Builder.CreateMinNum(Src0, Src2);
} else if (match(Src2, PatternMatch::m_NaN()) || isa<UndefValue>(Src2)) {
- NewCall = IC.Builder.CreateMaxNum(Src0, Src1);
+ V = IC.Builder.CreateMaxNum(Src0, Src1);
}
- if (NewCall) {
- NewCall->copyFastMathFlags(&II);
- NewCall->takeName(&II);
- return IC.replaceInstUsesWith(II, NewCall);
+ if (V) {
+ if (auto *CI = dyn_cast<CallInst>(V)) {
----------------
dtcxzyw wrote:
```suggestion
if (CallInst *CI = dyn_cast<CallInst>(V)) {
```
https://github.com/llvm/llvm-project/pull/80743
More information about the llvm-commits
mailing list