forked from OSchip/llvm-project
[DAGCombiner] Call ExtendUsesToFormExtLoad in (zext (and (load)))->(and (zextload)) even when the and does not have multiple uses
Same for the sign extend case. Currently we check for multiple uses on the binop. Then we call ExtendUsesToFormExtLoad to capture SetCCs that use the load. So we only end up finding any setccs when the and has additional uses and the load is used by a setcc. I don't think the and having multiple uses is relevant here. I think we should only be checking for the load having multiple uses. This changes an NVPTX test because we now find that the load has a second use by a truncate, but ExtendUsesToFormExtLoad only looks at setccs it can extend. All other operations just check isTruncateFree. Maybe we should allow widening of an existing truncate even if its not free? Differential Revision: https://reviews.llvm.org/D43063 llvm-svn: 325289
This commit is contained in:
parent
87412d95e3
commit
dac3c1f5c8
|
@ -7306,12 +7306,12 @@ static SDNode *tryToFoldExtendOfConstant(SDNode *N, const TargetLowering &TLI,
|
|||
// "fold ({s|z|a}ext (load x)) -> ({s|z|a}ext (truncate ({s|z|a}extload x)))"
|
||||
// transformation. Returns true if extension are possible and the above
|
||||
// mentioned transformation is profitable.
|
||||
static bool ExtendUsesToFormExtLoad(SDNode *N, SDValue N0,
|
||||
static bool ExtendUsesToFormExtLoad(EVT VT, SDNode *N, SDValue N0,
|
||||
unsigned ExtOpc,
|
||||
SmallVectorImpl<SDNode *> &ExtendNodes,
|
||||
const TargetLowering &TLI) {
|
||||
bool HasCopyToRegUses = false;
|
||||
bool isTruncFree = TLI.isTruncateFree(N->getValueType(0), N0.getValueType());
|
||||
bool isTruncFree = TLI.isTruncateFree(VT, N0.getValueType());
|
||||
for (SDNode::use_iterator UI = N0.getNode()->use_begin(),
|
||||
UE = N0.getNode()->use_end();
|
||||
UI != UE; ++UI) {
|
||||
|
@ -7425,7 +7425,7 @@ SDValue DAGCombiner::CombineExtLoad(SDNode *N) {
|
|||
return SDValue();
|
||||
|
||||
SmallVector<SDNode *, 4> SetCCs;
|
||||
if (!ExtendUsesToFormExtLoad(N, N0, N->getOpcode(), SetCCs, TLI))
|
||||
if (!ExtendUsesToFormExtLoad(DstVT, N, N0, N->getOpcode(), SetCCs, TLI))
|
||||
return SDValue();
|
||||
|
||||
ISD::LoadExtType ExtType =
|
||||
|
@ -7604,7 +7604,8 @@ SDValue DAGCombiner::visitSIGN_EXTEND(SDNode *N) {
|
|||
bool DoXform = true;
|
||||
SmallVector<SDNode*, 4> SetCCs;
|
||||
if (!N0.hasOneUse())
|
||||
DoXform = ExtendUsesToFormExtLoad(N, N0, ISD::SIGN_EXTEND, SetCCs, TLI);
|
||||
DoXform = ExtendUsesToFormExtLoad(VT, N, N0, ISD::SIGN_EXTEND, SetCCs,
|
||||
TLI);
|
||||
if (VT.isVector())
|
||||
DoXform &= TLI.isVectorLoadExtDesirable(SDValue(N, 0));
|
||||
if (DoXform) {
|
||||
|
@ -7660,11 +7661,9 @@ SDValue DAGCombiner::visitSIGN_EXTEND(SDNode *N) {
|
|||
EVT MemVT = LN00->getMemoryVT();
|
||||
if (TLI.isLoadExtLegal(ISD::SEXTLOAD, VT, MemVT) &&
|
||||
LN00->getExtensionType() != ISD::ZEXTLOAD && LN00->isUnindexed()) {
|
||||
bool DoXform = true;
|
||||
SmallVector<SDNode*, 4> SetCCs;
|
||||
if (!N0.hasOneUse())
|
||||
DoXform = ExtendUsesToFormExtLoad(N, N0.getOperand(0), ISD::SIGN_EXTEND,
|
||||
SetCCs, TLI);
|
||||
bool DoXform = ExtendUsesToFormExtLoad(VT, N0.getNode(), N0.getOperand(0),
|
||||
ISD::SIGN_EXTEND, SetCCs, TLI);
|
||||
if (DoXform) {
|
||||
SDValue ExtLoad = DAG.getExtLoad(ISD::SEXTLOAD, SDLoc(LN00), VT,
|
||||
LN00->getChain(), LN00->getBasePtr(),
|
||||
|
@ -7913,7 +7912,8 @@ SDValue DAGCombiner::visitZERO_EXTEND(SDNode *N) {
|
|||
bool DoXform = true;
|
||||
SmallVector<SDNode*, 4> SetCCs;
|
||||
if (!N0.hasOneUse())
|
||||
DoXform = ExtendUsesToFormExtLoad(N, N0, ISD::ZERO_EXTEND, SetCCs, TLI);
|
||||
DoXform = ExtendUsesToFormExtLoad(VT, N, N0, ISD::ZERO_EXTEND, SetCCs,
|
||||
TLI);
|
||||
if (VT.isVector())
|
||||
DoXform &= TLI.isVectorLoadExtDesirable(SDValue(N, 0));
|
||||
if (DoXform) {
|
||||
|
@ -7966,10 +7966,10 @@ SDValue DAGCombiner::visitZERO_EXTEND(SDNode *N) {
|
|||
if (isAndLoadExtLoad(AndC, LN00, LoadResultTy, ExtVT))
|
||||
DoXform = false;
|
||||
}
|
||||
if (DoXform)
|
||||
DoXform = ExtendUsesToFormExtLoad(N, N0.getOperand(0),
|
||||
ISD::ZERO_EXTEND, SetCCs, TLI);
|
||||
}
|
||||
if (DoXform)
|
||||
DoXform = ExtendUsesToFormExtLoad(VT, N0.getNode(), N0.getOperand(0),
|
||||
ISD::ZERO_EXTEND, SetCCs, TLI);
|
||||
if (DoXform) {
|
||||
SDValue ExtLoad = DAG.getExtLoad(ISD::ZEXTLOAD, SDLoc(LN00), VT,
|
||||
LN00->getChain(), LN00->getBasePtr(),
|
||||
|
@ -8157,7 +8157,8 @@ SDValue DAGCombiner::visitANY_EXTEND(SDNode *N) {
|
|||
bool DoXform = true;
|
||||
SmallVector<SDNode*, 4> SetCCs;
|
||||
if (!N0.hasOneUse())
|
||||
DoXform = ExtendUsesToFormExtLoad(N, N0, ISD::ANY_EXTEND, SetCCs, TLI);
|
||||
DoXform = ExtendUsesToFormExtLoad(VT, N, N0, ISD::ANY_EXTEND, SetCCs,
|
||||
TLI);
|
||||
if (DoXform) {
|
||||
LoadSDNode *LN0 = cast<LoadSDNode>(N0);
|
||||
SDValue ExtLoad = DAG.getExtLoad(ISD::EXTLOAD, SDLoc(N), VT,
|
||||
|
|
|
@ -23,10 +23,11 @@
|
|||
; CHECK: .func (.param .b32 func_retval0)
|
||||
; CHECK-LABEL: test_i1(
|
||||
; CHECK-NEXT: .param .b32 test_i1_param_0
|
||||
; CHECK: ld.param.u8 [[A8:%r[0-9]+]], [test_i1_param_0];
|
||||
; CHECK: and.b32 [[A:%r[0-9]+]], [[A8]], 1;
|
||||
; CHECK: ld.param.u8 [[A8:%rs[0-9]+]], [test_i1_param_0];
|
||||
; CHECK: and.b16 [[A:%rs[0-9]+]], [[A8]], 1;
|
||||
; CHECK: cvt.u32.u16 [[B:%r[0-9]+]], [[A]]
|
||||
; CHECK: .param .b32 param0;
|
||||
; CHECK: st.param.b32 [param0+0], [[A]]
|
||||
; CHECK: st.param.b32 [param0+0], [[B]]
|
||||
; CHECK: .param .b32 retval0;
|
||||
; CHECK: call.uni
|
||||
; CHECK-NEXT: test_i1,
|
||||
|
|
Loading…
Reference in New Issue