[PATCH] D62897: [DAGCombine] Initialize the bytes offset vector as INT64_MAX to avoid inference the endian check
Qing Shan Zhang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 5 19:21:53 PDT 2019
steven.zhang updated this revision to Diff 203279.
steven.zhang added a comment.
Address comments. Early return if it has been set before, to make the code more robust.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62897/new/
https://reviews.llvm.org/D62897
Files:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/PowerPC/store-combine.ll
Index: llvm/test/CodeGen/PowerPC/store-combine.ll
===================================================================
--- llvm/test/CodeGen/PowerPC/store-combine.ll
+++ llvm/test/CodeGen/PowerPC/store-combine.ll
@@ -574,3 +574,23 @@
store i8 %conv5, i8* %arrayidx6, align 1
ret void
}
+; This was found when testing the hexxagon in testsuite
+; i8* p; i8 v;
+; p[0] = v;
+; p[1] = v;
+define void @store_same_value_to_consecutive_mem(i8* %p, i8 zeroext %v) {
+; CHECK-PPC64LE-LABEL: store_same_value_to_consecutive_mem
+; CHECK-PPC64LE: # %bb.0: # %entry
+; CHECK-PPC64LE-NEXT: stb 4, 0(3)
+; CHECK-PPC64LE-NEXT: stb 4, 1(3)
+;
+; CHECK-PPC64-LABEL: store_same_value_to_consecutive_mem
+; CHECK-PPC64: # %bb.0: # %entry
+; CHECK-PPC64-NEXT: stb 4, 0(3)
+; CHECK-PPC64-NEXT: stb 4, 1(3)
+entry:
+ store i8 %v, i8* %p, align 1
+ %arrayidx1 = getelementptr inbounds i8, i8* %p, i64 1
+ store i8 %v, i8* %arrayidx1, align 1
+ ret void
+}
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -6304,7 +6304,7 @@
// to the same base address. Collect bytes offsets from Base address into
// ByteOffsets.
SDValue CombinedValue;
- SmallVector<int64_t, 4> ByteOffsets(Width);
+ SmallVector<int64_t, 4> ByteOffsets(Width, INT64_MAX);
int64_t FirstOffset = INT64_MAX;
StoreSDNode *FirstStore = nullptr;
Optional<BaseIndexOffset> Base;
@@ -6365,8 +6365,9 @@
FirstStore = Store;
FirstOffset = ByteOffsetFromBase;
}
- // Map the offset in the store and the offset in the combined value.
- if (Offset < 0 || Offset >= Width)
+ // Map the offset in the store and the offset in the combined value, and
+ // early return if it has been set before.
+ if (Offset < 0 || Offset >= Width || ByteOffsets[Offset] != INT64_MAX)
return SDValue();
ByteOffsets[Offset] = ByteOffsetFromBase;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62897.203279.patch
Type: text/x-patch
Size: 2045 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190606/f8d8bee6/attachment.bin>
More information about the llvm-commits
mailing list