[PATCH] D48556: Fix asserts in AMDGCN fmed3 folding by handling more cases of NaN

Alan Baker via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 25 13:49:09 PDT 2018


alan-baker added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstCombineCalls.cpp:3447-3452
+    if (match(Src2, m_NaN()) || isa<UndefValue>(Src2)) {
+      CallInst *NewCall = Builder.CreateMaxNum(Src0, Src1);
+      NewCall->copyFastMathFlags(II);
+      NewCall->takeName(II);
+      return replaceInstUsesWith(*II, NewCall);
+    }
----------------
arsenm wrote:
> I don't really like repeating all of these so many times, but it's probably clearer than the alternatives. Should this used FastMathFlagGuard to avoid repeating the copyFastMathFlags at least?
Calls don't automatically inherit fast math flags from the builder so creating the guard doesn't work. If it's preferable, I could refactor to create the call instruction first and in a subsequent if take the name and copy the fast math flags.


Repository:
  rL LLVM

https://reviews.llvm.org/D48556





More information about the llvm-commits mailing list