Skip to content

[X86] Add missed type extension and truncation during combine #67168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions llvm/lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49820,9 +49820,9 @@ static SDValue combineLoad(SDNode *N, SelectionDAG &DAG,
if (PtrVT != Ld->getBasePtr().getSimpleValueType()) {
SDValue Cast =
DAG.getAddrSpaceCast(dl, PtrVT, Ld->getBasePtr(), AddrSpace, 0);
return DAG.getLoad(RegVT, dl, Ld->getChain(), Cast, Ld->getPointerInfo(),
Ld->getOriginalAlign(),
Ld->getMemOperand()->getFlags());
return DAG.getExtLoad(Ext, dl, RegVT, Ld->getChain(), Cast,
Ld->getPointerInfo(), MemVT, Ld->getOriginalAlign(),
Ld->getMemOperand()->getFlags());
}
}

Expand Down Expand Up @@ -50324,9 +50324,10 @@ static SDValue combineStore(SDNode *N, SelectionDAG &DAG,
if (PtrVT != St->getBasePtr().getSimpleValueType()) {
SDValue Cast =
DAG.getAddrSpaceCast(dl, PtrVT, St->getBasePtr(), AddrSpace, 0);
return DAG.getStore(St->getChain(), dl, StoredVal, Cast,
St->getPointerInfo(), St->getOriginalAlign(),
St->getMemOperand()->getFlags(), St->getAAInfo());
return DAG.getTruncStore(
St->getChain(), dl, StoredVal, Cast, St->getPointerInfo(), StVT,
St->getOriginalAlign(), St->getMemOperand()->getFlags(),
St->getAAInfo());
}
}

Expand Down
21 changes: 15 additions & 6 deletions llvm/test/CodeGen/X86/mixed-ptr-sizes.ll
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ define i64 @test_load_sptr32_zext_i64(ptr addrspace(270) %i) {
; CHECK-LABEL: test_load_sptr32_zext_i64:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: movslq %ecx, %rax
; CHECK-NEXT: movq (%rax), %rax
; CHECK-NEXT: movl (%rax), %eax
; CHECK-NEXT: retq
;
; CHECK-O0-LABEL: test_load_sptr32_zext_i64:
Expand All @@ -278,11 +278,20 @@ entry:
}

define void @test_store_sptr32_trunc_i1(ptr addrspace(270) %s, i32 %i) {
; ALL-LABEL: test_store_sptr32_trunc_i1:
; ALL: # %bb.0: # %entry
; ALL-NEXT: movslq %ecx, %rax
; ALL-NEXT: movl %edx, (%rax)
; ALL-NEXT: retq
; CHECK-LABEL: test_store_sptr32_trunc_i1:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: movslq %ecx, %rax
; CHECK-NEXT: andl $1, %edx
; CHECK-NEXT: movb %dl, (%rax)
; CHECK-NEXT: retq
;
; CHECK-O0-LABEL: test_store_sptr32_trunc_i1:
; CHECK-O0: # %bb.0: # %entry
; CHECK-O0-NEXT: movslq %ecx, %rax
; CHECK-O0-NEXT: andl $1, %edx
; CHECK-O0-NEXT: movb %dl, %cl
; CHECK-O0-NEXT: movb %cl, (%rax)
; CHECK-O0-NEXT: retq
entry:
%0 = trunc i32 %i to i1
store i1 %0, ptr addrspace(270) %s
Expand Down