]> granicus.if.org Git - llvm/commit
[TargetLowering][AMDGPU] Remove the SimplifyDemandedBits function that takes a User...
authorCraig Topper <craig.topper@intel.com>
Mon, 7 Jan 2019 19:30:43 +0000 (19:30 +0000)
committerCraig Topper <craig.topper@intel.com>
Mon, 7 Jan 2019 19:30:43 +0000 (19:30 +0000)
commit2d88ada4d7b9b375819e43a616a1f94e9a271472
treeb4a178ef5a7ec8edaf3707f5ce5d23f7d9c40b7d
parent8ed7a6f2579cec6d3122d4c2df8c361dbe1117d6
[TargetLowering][AMDGPU] Remove the SimplifyDemandedBits function that takes a User and OpIdx. Stop using it in AMDGPU target for simplifyI24.

As we saw in D56057 when we tried to use this function on X86, it's unsafe. It allows the operand node to have multiple users, but doesn't prevent recursing past the first node when it does have multiple users. This can cause other simplifications earlier in the graph without regard to what bits are needed by the other users of the first node. Ideally all we should do to the first node if it has multiple uses is bypass it when its not needed by the user we started from. Doing any other transformation that SimplifyDemandedBits can do like turning ZEXT/SEXT into AEXT would result in an increase in instructions.

Fortunately, we already have a function that can do just that, GetDemandedBits. It will only make transformations that involve bypassing a node.

This patch changes AMDGPU's simplifyI24, to use a combination of GetDemandedBits to handle the multiple use simplifications. And then uses the regular SimplifyDemandedBits on each operand to handle simplifications allowed when the operand only has a single use. Unfortunately, GetDemandedBits simplifies constants more aggressively than SimplifyDemandedBits. This caused the -7 constant in the changed test to be simplified to remove the upper bits. I had to modify computeKnownBits to account for this by ignoring the upper 8 bits of the input.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350560 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/CodeGen/TargetLowering.h
lib/CodeGen/SelectionDAG/TargetLowering.cpp
lib/Target/AMDGPU/AMDGPUISelLowering.cpp
test/CodeGen/AMDGPU/lshl64-to-32.ll