OSDN Git Service

[X86] Turn X86ISD::AND nodes that have no flag users back into ISD::AND just before...
authorCraig Topper <craig.topper@intel.com>
Thu, 1 Feb 2018 17:08:39 +0000 (17:08 +0000)
committerCraig Topper <craig.topper@intel.com>
Thu, 1 Feb 2018 17:08:39 +0000 (17:08 +0000)
commit7cca90c1c128424a742b0cb75f1aa575ae4d83c3
tree83464a5bf5f839e5a1634321bb7f0504b5c48027
parentf712d3af436c7d64ea1aa580bcbbe227c8352f47
[X86] Turn X86ISD::AND nodes that have no flag users back into ISD::AND just before isel to enable test instruction matching

Summary:
EmitTest sometimes creates X86ISD::AND specifically to hide the AND from DAG combine. But this prevents isel patterns that look for (cmp (and X, Y), 0) from being able to see it. So we end up with an AND and a TEST. The TEST gets removed by compare instruction optimization during the peephole pass.

This patch attempts to fix this by converting X86ISD::AND with no flag users back into ISD::AND during the DAG preprocessing just before isel.

In order to do this correctly I had to make the X86ISD::AND node created by EmitTest in this case really have a flag output. Which arguably it should have had anyway so that the number of operands would be consistent for the opcode in all cases. Then I had to modify the ReplaceAllUsesWith to understand that we might be looking at an instruction with 2 outputs. Though in this case there are no uses to replace since we just created the node, but that's what the code did before so I just made it keep working.

Reviewers: spatel, RKSimon, niravd, deadalnix

Reviewed By: RKSimon

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D42764

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323982 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelDAGToDAG.cpp
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/2012-08-16-setcc.ll
test/CodeGen/X86/jump_sign.ll
test/CodeGen/X86/test-shrink-bug.ll