[llvm] 5dc9c39 - [GlobalISel] Check the correct register in sextload OneUse check. (#114763)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 5 02:18:11 PST 2024
Author: David Green
Date: 2024-11-05T10:18:07Z
New Revision: 5dc9c39ac15be0a8c0dd8ee1fb1c9f6f86691592
URL: https://github.com/llvm/llvm-project/commit/5dc9c39ac15be0a8c0dd8ee1fb1c9f6f86691592
DIFF: https://github.com/llvm/llvm-project/commit/5dc9c39ac15be0a8c0dd8ee1fb1c9f6f86691592.diff
LOG: [GlobalISel] Check the correct register in sextload OneUse check. (#114763)
This fixes a bug that started triggering after #111730, where we could
remove a load with multiple uses. It looks like the match should be
checking the other register in a one-use check.
%SrcReg = load..
%DstReg = sign_extend_inreg %SrcReg
Added:
Modified:
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
llvm/test/CodeGen/AArch64/load.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index 9a1aa27dd95423..ede8d82fc1a35e 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -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();
diff --git a/llvm/test/CodeGen/AArch64/load.ll b/llvm/test/CodeGen/AArch64/load.ll
index 543605a0a09296..3fa5d64a210e19 100644
--- a/llvm/test/CodeGen/AArch64/load.ll
+++ b/llvm/test/CodeGen/AArch64/load.ll
@@ -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
+}
More information about the llvm-commits
mailing list