[PATCH] D12680: [InstCombine] Added vector demanded bits support for SSE4A EXTRQ/INSERTQ instructions

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 14 15:33:23 PDT 2015


spatel added inline comments.

================
Comment at: lib/Transforms/InstCombine/InstCombineCalls.cpp:934-935
@@ +933,4 @@
+    // operands and the lowest 16-bits of the second.
+    auto Op0 = II->getArgOperand(0);
+    auto Op1 = II->getArgOperand(1);
+    unsigned VWidth0 = cast<VectorType>(Op0->getType())->getNumElements();
----------------
Use 'auto *' for pointers? Same comment for the other autos below.

================
Comment at: lib/Transforms/InstCombine/InstCombineCalls.cpp:972-986
@@ +971,17 @@
+
+  case Intrinsic::x86_sse4a_insertq: {
+    // INSERTQ uses only the lowest 64-bits of the first 128-bit vector
+    // operand.
+    auto Op = II->getArgOperand(0);
+    unsigned VWidth = cast<VectorType>(Op->getType())->getNumElements();
+    assert(VWidth == 2 && "Unexpected operand size");
+
+    APInt DemandedElts = APInt::getLowBitsSet(VWidth, 1);
+    APInt UndefElts(VWidth, 0);
+    if (Value *V = SimplifyDemandedVectorElts(Op, DemandedElts, UndefElts)) {
+      II->setArgOperand(0, V);
+      return II;
+    }
+    break;
+  }
+
----------------
Isn't this identical to the extrqi case? If yes, combine cases and eliminate the duplicated code. Could also just add a 3-4 line helper function that can be used for all of the cases?


Repository:
  rL LLVM

http://reviews.llvm.org/D12680





More information about the llvm-commits mailing list