[llvm] [GlobalISel] Check the correct register in sextload OneUse check. (PR #114763)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 4 01:00:56 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-aarch64
Author: David Green (davemgreen)
<details>
<summary>Changes</summary>
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.
%SrcReg = load..
%DstReg = sign_extend_inreg %SrcReg
---
Full diff: https://github.com/llvm/llvm-project/pull/114763.diff
2 Files Affected:
- (modified) llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp (+1-1)
- (modified) llvm/test/CodeGen/AArch64/load.ll (+14)
``````````diff
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index 7c1bda2163b7a0..1f2baa3fa9c0f8 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
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/114763
More information about the llvm-commits
mailing list