[llvm] r367737 - [GlobalISel] Check LLT size matches memory size for non-truncating stores.
Amara Emerson via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 2 16:33:14 PDT 2019
Author: aemerson
Date: Fri Aug 2 16:33:13 2019
New Revision: 367737
URL: http://llvm.org/viewvc/llvm-project?rev=367737&view=rev
Log:
[GlobalISel] Check LLT size matches memory size for non-truncating stores.
This was causing a bug where non-truncating stores would be selected instead of truncating ones.
Differential Revision: https://reviews.llvm.org/D64845
Modified:
llvm/trunk/test/TableGen/address-space-patfrags.td
llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp
Modified: llvm/trunk/test/TableGen/address-space-patfrags.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/address-space-patfrags.td?rev=367737&r1=367736&r2=367737&view=diff
==============================================================================
--- llvm/trunk/test/TableGen/address-space-patfrags.td (original)
+++ llvm/trunk/test/TableGen/address-space-patfrags.td Fri Aug 2 16:33:13 2019
@@ -44,6 +44,11 @@ def inst_c : Instruction {
let InOperandList = (ins GPR32:$src0, GPR32:$src1);
}
+def inst_d : Instruction {
+ let OutOperandList = (outs);
+ let InOperandList = (ins GPR32:$src0, GPR32:$src1);
+}
+
// SDAG: case 2: {
// SDAG-NEXT: // Predicate_pat_frag_b
// SDAG-NEXT: SDNode *N = Node;
@@ -115,10 +120,20 @@ def : Pat <
(inst_c GPR32:$src0, GPR32:$src1)
>;
-// Test truncstore with specific MemoryVT
+// Test non-truncstore has a size equal to LLT check.
// GISEL: GIM_Try, /*On fail goto*//*Label 3*/ {{[0-9]+}}, // Rule ID 3 //
// GISEL-NEXT: GIM_CheckNumOperands, /*MI*/0, /*Expected*/2,
// GISEL-NEXT: GIM_CheckOpcode, /*MI*/0, TargetOpcode::G_STORE,
+// GISEL-NEXT: GIM_CheckMemorySizeEqualToLLT, /*MI*/0, /*MMO*/0, /*OpIdx*/0,
+def : Pat <
+ (store GPR32:$src0, GPR32:$src1),
+ (inst_d GPR32:$src0, GPR32:$src1)
+>;
+
+// Test truncstore with specific MemoryVT
+// GISEL: GIM_Try, /*On fail goto*//*Label 4*/ {{[0-9]+}}, // Rule ID 4 //
+// GISEL-NEXT: GIM_CheckNumOperands, /*MI*/0, /*Expected*/2,
+// GISEL-NEXT: GIM_CheckOpcode, /*MI*/0, TargetOpcode::G_STORE,
// GISEL-NEXT: GIM_CheckMemorySizeLessThanLLT, /*MI*/0, /*MMO*/0, /*OpIdx*/0,
// GISEL-NEXT: GIM_CheckMemoryAddressSpace, /*MI*/0, /*MMO*/0, /*NumAddrSpace*/2, /*AddrSpace*/123, /*AddrSpace*/455,
// GISEL-NEXT: GIM_CheckMemorySizeEqualTo, /*MI*/0, /*MMO*/0, /*Size*/2,
Modified: llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp?rev=367737&r1=367736&r2=367737&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp Fri Aug 2 16:33:13 2019
@@ -3347,11 +3347,19 @@ Expected<InstructionMatcher &> GlobalISe
continue;
}
- if (Predicate.isStore() && Predicate.isTruncStore()) {
- // FIXME: If MemoryVT is set, we end up with 2 checks for the MMO size.
- InsnMatcher.addPredicate<MemoryVsLLTSizePredicateMatcher>(
- 0, MemoryVsLLTSizePredicateMatcher::LessThan, 0);
- continue;
+ if (Predicate.isStore()) {
+ if (Predicate.isTruncStore()) {
+ // FIXME: If MemoryVT is set, we end up with 2 checks for the MMO size.
+ InsnMatcher.addPredicate<MemoryVsLLTSizePredicateMatcher>(
+ 0, MemoryVsLLTSizePredicateMatcher::LessThan, 0);
+ continue;
+ }
+ if (Predicate.isNonTruncStore()) {
+ // We need to check the sizes match here otherwise we could incorrectly
+ // match truncating stores with non-truncating ones.
+ InsnMatcher.addPredicate<MemoryVsLLTSizePredicateMatcher>(
+ 0, MemoryVsLLTSizePredicateMatcher::EqualTo, 0);
+ }
}
// No check required. We already did it by swapping the opcode.
More information about the llvm-commits
mailing list