Skip to content

Commit 8262f45

Browse files
committed
[InstCombine] Add additional store forwarding test (NFC)
Variant where the load is larger than the store. Make sure we don't forward this.
1 parent fdb66ed commit 8262f45

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

llvm/test/Transforms/InstCombine/load-store-forward.ll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ define i8 @load_smaller_int(i16* %p) {
1818
ret i8 %load
1919
}
2020

21+
; This case can *not* be forwarded, as we only see part of the stored value.
22+
define i32 @load_larger_int(i16* %p) {
23+
; CHECK-LABEL: @load_larger_int(
24+
; CHECK-NEXT: store i16 258, i16* [[P:%.*]], align 2
25+
; CHECK-NEXT: [[P2:%.*]] = bitcast i16* [[P]] to i32*
26+
; CHECK-NEXT: [[LOAD:%.*]] = load i32, i32* [[P2]], align 4
27+
; CHECK-NEXT: ret i32 [[LOAD]]
28+
;
29+
store i16 258, i16* %p
30+
%p2 = bitcast i16* %p to i32*
31+
%load = load i32, i32* %p2
32+
ret i32 %load
33+
}
34+
2135
define i32 @vec_store_load_first(i32* %p) {
2236
; CHECK-LABEL: @vec_store_load_first(
2337
; CHECK-NEXT: [[P2:%.*]] = bitcast i32* [[P:%.*]] to <2 x i32>*

0 commit comments

Comments
 (0)