[PATCH] D47805: [AMDGPU] Improve reciprocal handling

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 6 10:28:22 PDT 2018


rampitec added inline comments.


================
Comment at: lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp:376
+static bool shouldKeepFDivF32(Value *Num, bool UnsafeDiv, bool HasDenormals) {
   const ConstantFP *CNum = dyn_cast<ConstantFP>(Num);
   if (!CNum)
----------------
arsenm wrote:
> I think if you use the stuff in PatternMatch.h you can easily check for constant splats if you want this to work for vectors too
It now can work on an arbitrary constant vector, not splat only. Then this helper is used on an element. There is even a test for non-splat.


================
Comment at: lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp:423
+  if (shouldKeepFDivF32(Num, UnsafeDiv, HasDenormals) &&
+      !isa<ConstantDataVector>(Num))
+    return false;
----------------
arsenm wrote:
> Check constant first? Also isn't just isa<Constant> sufficient? Not sure why this needs to check it at all since shouldKeepFDivF32 already checks this
Check for constant only is not sufficient. It can replace fdiv when a numerator is not constant and no denorms. But I have removed it all together because it will be checked later anyway.


https://reviews.llvm.org/D47805





More information about the llvm-commits mailing list