[PATCH] D34077: DAGCombine: Combine BUILD_VECTOR to TRUNCATE

Zvi Rackover via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 3 07:34:17 PDT 2017


zvi added inline comments.


================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:14272
+  // Proceed only if the stride and the types can be matched to a truncate.
+  if ((Stride == 1 || !isPowerOf2_32(Stride)) ||
+      (ExtractedFromVec.getValueType().getVectorNumElements() !=
----------------
delena wrote:
> I'd check (Stride < 2), I don't know what isPowerOf2_32() thinks about 0.
 isPowerOf2_32(0) should return false. From a quick look at the implementation this is the case. I will add a case in unittests/Support/MathExtrasTest.cpp to make sure this is covered.


================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:14296
+  Res = DAG.getNode(ISD::TRUNCATE, SDLoc(N), TruncVT, Res);
+  if (VT.isFloatingPoint())
+    Res = DAG.getBitcast(VT, Res);
----------------
delena wrote:
> you can just call for getBitcast(VT, Res), the "getBitcast() has the "if" inside".
ok.


https://reviews.llvm.org/D34077





More information about the llvm-commits mailing list