[PATCH] D34416: [CGP] eliminate a sub instruction in memcmp expansion

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 20 12:52:12 PDT 2017


spatel created this revision.
Herald added a subscriber: mcrosier.

As noted in https://reviews.llvm.org/D34071, there are some IR optimization opportunities that could be handled by normal IR passes if this expansion wasn't happening so late in CGP.

Regardless of that, it seems wasteful to knowingly produce suboptimal IR here, so I'm proposing this change:
%s = sub i32 %x, %y
%r = icmp ne %s, 0

  =>

%r = icmp ne %x, %y

Changing the predicate to 'eq' mimics what InstCombine would do, so that's just an efficiency improvement if we decide this expansion should happen sooner.

The fact that the PowerPC backend doesn't eliminate the 'subf.' might be something for PPC folks to investigate separately.


https://reviews.llvm.org/D34416

Files:
  lib/CodeGen/CodeGenPrepare.cpp
  test/CodeGen/PowerPC/memCmpUsedInZeroEqualityComparison.ll
  test/CodeGen/PowerPC/memcmp.ll
  test/CodeGen/PowerPC/memcmpIR.ll
  test/CodeGen/X86/memcmp.ll
  test/Transforms/CodeGenPrepare/X86/memcmp.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34416.103255.patch
Type: text/x-patch
Size: 24899 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170620/7e3de1dd/attachment.bin>


More information about the llvm-commits mailing list