[PATCH] D47805: [AMDGPU] Improve reciprocal handling

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 6 06:38:08 PDT 2018


arsenm 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)
----------------
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


================
Comment at: lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp:386-389
+  if (!HasDenormals)
+    return IsOne;
+
+  return !IsOne;
----------------
Merge into a return of the logically combined condition


================
Comment at: lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp:423
+  if (shouldKeepFDivF32(Num, UnsafeDiv, HasDenormals) &&
+      !isa<ConstantDataVector>(Num))
+    return false;
----------------
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


================
Comment at: test/CodeGen/AMDGPU/fdiv32-to-rcp-folding.ll:98-101
+; GCN-DENORM-DAG: v_mul_f32_e32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}
+; GCN-DENORM-DAG: v_mul_f32_e32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}
+; GCN-DENORM-DAG: v_mul_f32_e32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}
+; GCN-DENORM-DAG: v_mul_f32_e32 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}
----------------
This will only effectively check for one, although I think there's a FileCheck patch out for review to fix this


https://reviews.llvm.org/D47805





More information about the llvm-commits mailing list