Skip to content

[GlobalISel] Check the correct register in sextload OneUse check. #114763

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
Nov 5, 2024
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
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ bool CombinerHelper::matchSextInRegOfLoad(

Register SrcReg = MI.getOperand(1).getReg();
auto *LoadDef = getOpcodeDef<GLoad>(SrcReg, MRI);
if (!LoadDef || !MRI.hasOneNonDBGUse(DstReg))
if (!LoadDef || !MRI.hasOneNonDBGUse(SrcReg))
return false;

uint64_t MemBits = LoadDef->getMemSizeInBits().getValue();
Expand Down
14 changes: 14 additions & 0 deletions llvm/test/CodeGen/AArch64/load.ll
Original file line number Diff line number Diff line change
Expand Up @@ -465,3 +465,17 @@ define <2 x fp128> @load_v2f128(ptr %p) {
%a = load <2 x fp128>, ptr %p
ret <2 x fp128> %a
}

define i32 @load_i8_s16_extrasuse(ptr %ptr, ptr %ptr2) {
; CHECK-LABEL: load_i8_s16_extrasuse:
; CHECK: // %bb.0:
; CHECK-NEXT: ldr w8, [x0]
; CHECK-NEXT: sxtb w0, w8
; CHECK-NEXT: str w8, [x1]
; CHECK-NEXT: ret
%a = load i32, ptr %ptr
%s = shl i32 %a, 24
%b = ashr i32 %s, 24
store i32 %a, ptr %ptr2
ret i32 %b
}
Loading