[PATCH] D34141: [X86] Recognize constant arrays with special values and replace loads from it with subtract and shift instructions, which then may be replaced by BZHI machine instruction.

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 21 05:49:31 PDT 2017


RKSimon added subscribers: filcab, davide.
RKSimon added a comment.

While I don't want to end up forcing you to over-engineer this, it seems this pass is currently very specific and should be generalised to make it straightforward to work for constants arrays of other patterns that are easily re-materializable (upper/lower masks, single bit masks, etc.) - "SubstituteLoadWithRematerializationPass", possibly driven by the TTI cost models?



================
Comment at: lib/CodeGen/SubstituteLoadWithSubShr.cpp:70
+  if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(LI->getOperand(0))) {
+    if (GlobalVariable *GV = dyn_cast<GlobalVariable>(GEP->getOperand(0))) {
+      if (GV->isConstant() && GV->hasDefinitiveInitializer()) {
----------------
(style) Don't nest these - do an early-out if they are null


================
Comment at: lib/CodeGen/SubstituteLoadWithSubShr.cpp:146
+
+  return Changed;
+}
----------------
(style) Remove all the extra braces.


https://reviews.llvm.org/D34141





More information about the llvm-commits mailing list