[PATCH] D28813: [CodeGenPrepare] Sink and duplicate more 'and' instructions.

Geoff Berry via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 19 14:44:28 PST 2017


gberry marked 2 inline comments as done.
gberry added inline comments.


================
Comment at: lib/CodeGen/CodeGenPrepare.cpp:1105
+
+  if (!TLI.isMaskAndCmp0FoldingBeneficial(*AndI))
+    return false;
----------------
mcrosier wrote:
> minor nit: Would it make sense for this check to be first?  That would avoid unnecessary work for those targets that don't enable this optimization.
Looking at this again, I'm tempted to move it down past the users loop since it is a virtual function call that is currently being made for nearly all 'and' instructions.


================
Comment at: lib/CodeGen/CodeGenPrepare.cpp:4699
       Builder.CreateAnd(Load, ConstantInt::get(Ctx, DemandBits)));
+  // Mark this instruction as "inserted by CGP", so that other
+  // optimizations don't touch it.
----------------
mcrosier wrote:
> I'm curious if this change in isolation prevented some other optimizations from happening?
It shouldn't but I can verify that it doesn't.


================
Comment at: test/CodeGen/X86/and-sink.ll:1
+; RUN: llc -march=x86 -verify-machineinstrs < %s | FileCheck %s
+
----------------
RKSimon wrote:
> Don't use -march - use -mtriple=i686-unknown
Will do.  Out of curiosity, why is this preferred?


https://reviews.llvm.org/D28813





More information about the llvm-commits mailing list