Skip to content

Commit 131f7ba

Browse files
committed
[llvm-exegesis] Add unit test in preparation for DD109275
1 parent 3e03d92 commit 131f7ba

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

llvm/unittests/tools/llvm-exegesis/X86/SnippetGeneratorTest.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,29 @@ TEST_F(X86SerialSnippetGeneratorTest,
154154
consumeError(std::move(Error));
155155
}
156156

157+
TEST_F(X86SerialSnippetGeneratorTest,
158+
AvoidSerializingThroughImplicitRegisters) {
159+
// MULX32rr implicitly uses EDX. We should not select that register to avoid
160+
// serialization.
161+
const unsigned Opcode = X86::MULX32rr;
162+
randomGenerator().seed(0); // Initialize seed.
163+
const Instruction &Instr = State.getIC().getInstr(Opcode);
164+
// Forbid all registers but RDX/EDX/DX/DH/DL. The only option would be to
165+
// choose that register, but that would serialize the instruction, so we
166+
// should be returning an error.
167+
auto AllRegisters = State.getRATC().emptyRegisters();
168+
AllRegisters.flip();
169+
AllRegisters.reset(X86::RDX);
170+
AllRegisters.reset(X86::EDX);
171+
AllRegisters.reset(X86::DX);
172+
AllRegisters.reset(X86::DH);
173+
AllRegisters.reset(X86::DL);
174+
auto Error =
175+
Generator.generateCodeTemplates(&Instr, AllRegisters).takeError();
176+
// FIXME: EXPECT_TRUE + consumeError(std::move(Error)).
177+
EXPECT_FALSE((bool)Error);
178+
}
179+
157180
TEST_F(X86SerialSnippetGeneratorTest, DependencyThroughOtherOpcode) {
158181
// - CMP64rr
159182
// - Op0 Explicit Use RegClass(GR64)

0 commit comments

Comments
 (0)