[PATCH] D42479: DAGCombiner: Combine SDIV with non-splat vector pow2 divider

Zvi Rackover via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 4 10:17:56 PST 2018


zvi added a comment.

In https://reviews.llvm.org/D42479#986607, @RKSimon wrote:

> How bad does the codegen get if we don't limit this to targets with vector shifts? Again, thinking AVX1 (Jaguar) here., but combine_vec_sdiv_by_pow2b_v4i64 looks like a missed opportunity


I think you are right. Probably all cases will profit except for v2i64. Will try to drop the TLI hook.



================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:2932
+    return true;
+  };
   // fold (sdiv X, pow2) -> simple ops after legalize
----------------
RKSimon wrote:
> Did you look at using matchBinaryPredicate here?
Thanks for suggesting. Will use it.


================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:2970
+      C1 = DAG.getBuildVector(VT, DL, Ops1);
+    }
 
----------------
RKSimon wrote:
> You can probably get the getNode/FoldConstantArithmetic methods to do most of this for you?
Will try to make the most of it. Unfortunately, there are two separate helpers: FoldConstantVectorArithmetic and FoldConstantArithmetic for vectors and scalars respectively, so there will still be a divergence. I noticed there is a TODO to join the two functions, so whenever we get to work on it, the divergence can be eliminated.


Repository:
  rL LLVM

https://reviews.llvm.org/D42479





More information about the llvm-commits mailing list