Skip to content

Commit 36b709d

Browse files
committed
[DAGCombiner] Fix mayAlias not accounting for scalable MMOs with offsets
In llvm#70452 DAGCombiner::mayAlias was taught to handle scalable vectors, but when it checks via AA->isNoAlias it didn't take into account the case where the size is scalable but there was an offset too. For the fixed length case the offset was just accounted for by adding to the LocationSize, but for the scalable case there doesn't seem to be a way to represent both a scalable and fixed part in it. So this patch works around it by bailing if there is an offset. Fixes llvm#90559
1 parent bd72f7b commit 36b709d

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28113,7 +28113,10 @@ bool DAGCombiner::mayAlias(SDNode *Op0, SDNode *Op1) const {
2811328113
#endif
2811428114

2811528115
if (UseAA && AA && MUC0.MMO->getValue() && MUC1.MMO->getValue() &&
28116-
Size0.hasValue() && Size1.hasValue()) {
28116+
Size0.hasValue() && Size1.hasValue() &&
28117+
// Can't represent a scalable size + fixed offset in LocationSize
28118+
!(Size0.isScalable() && SrcValOffset0 != 0) &&
28119+
!(Size1.isScalable() && SrcValOffset1 != 0)) {
2811728120
// Use alias analysis information.
2811828121
int64_t MinOffset = std::min(SrcValOffset0, SrcValOffset1);
2811928122
int64_t Overlap0 =

llvm/test/CodeGen/RISCV/rvv/pr90559.ll

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
22
; RUN: llc < %s -mtriple=riscv64 -mattr=+v | FileCheck %s
33

4-
; FIXME: The i32 load and store pair isn't dead and shouldn't be omitted.
54
define void @f(ptr %p) vscale_range(2,2) {
65
; CHECK-LABEL: f:
76
; CHECK: # %bb.0:
8-
; CHECK-NEXT: vsetvli a1, zero, e8, m4, ta, ma
9-
; CHECK-NEXT: vmv.v.i v8, 0
10-
; CHECK-NEXT: vs4r.v v8, (a0)
11-
; CHECK-NEXT: addi a1, a0, 80
7+
; CHECK-NEXT: lw a1, 84(a0)
8+
; CHECK-NEXT: addi a2, a0, 80
129
; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, ma
1310
; CHECK-NEXT: vmv.v.i v8, 0
14-
; CHECK-NEXT: vs1r.v v8, (a1)
15-
; CHECK-NEXT: addi a0, a0, 64
16-
; CHECK-NEXT: vs1r.v v8, (a0)
11+
; CHECK-NEXT: vs1r.v v8, (a2)
12+
; CHECK-NEXT: vsetvli a2, zero, e8, m4, ta, ma
13+
; CHECK-NEXT: vmv.v.i v12, 0
14+
; CHECK-NEXT: vs4r.v v12, (a0)
15+
; CHECK-NEXT: addi a2, a0, 64
16+
; CHECK-NEXT: vs1r.v v8, (a2)
17+
; CHECK-NEXT: sw a1, 84(a0)
1718
; CHECK-NEXT: ret
1819
%q = getelementptr inbounds i8, ptr %p, i64 84
1920
%x = load i32, ptr %q

0 commit comments

Comments
 (0)