-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[VPlan] Add VPInst::getNumOperandsForOpcode, use to verify in ctor (NFC) #142284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
2ab3df5
cd2f291
f58eadd
c134f89
e78eb44
0d8c982
ef1ba88
d2f5c26
0c8de77
031aeca
f829e30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -706,13 +706,15 @@ TEST_F(VPBasicBlockTest, reassociateBlocks) { | |
|
|
||
| #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) | ||
| TEST_F(VPBasicBlockTest, print) { | ||
| VPInstruction *TC = new VPInstruction(Instruction::Add, {}); | ||
| VPInstruction *TC = new VPInstruction(Instruction::PHI, {}); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To escape num operands check?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. The tests here just check the various print implementations, the actual opcodes/operands don't matter much, other than matching the print checks. There's a chicken-egg problem here, as we need to get a VPValue before calling getPlan. |
||
| VPlan &Plan = getPlan(TC); | ||
| IntegerType *Int32 = IntegerType::get(C, 32); | ||
| VPValue *Val = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 1)); | ||
| VPBasicBlock *VPBB0 = Plan.getEntry(); | ||
| VPBB0->appendRecipe(TC); | ||
|
|
||
| VPInstruction *I1 = new VPInstruction(Instruction::Add, {}); | ||
| VPInstruction *I2 = new VPInstruction(Instruction::Sub, {I1}); | ||
| VPInstruction *I1 = new VPInstruction(Instruction::Add, {Val, Val}); | ||
| VPInstruction *I2 = new VPInstruction(Instruction::Sub, {I1, Val}); | ||
| VPInstruction *I3 = new VPInstruction(Instruction::Br, {I1, I2}); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Independent: a branch has two VPInstruction operands?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, this just creates artificial VPInstructions to test printing, the ocpodes don't really matter, other than checking. We should probably tighten down which kinds of opcodes are supported for VPInstruction |
||
|
|
||
| VPBasicBlock *VPBB1 = Plan.createVPBasicBlock(""); | ||
|
|
@@ -722,7 +724,7 @@ TEST_F(VPBasicBlockTest, print) { | |
| VPBB1->setName("bb1"); | ||
|
|
||
| VPInstruction *I4 = new VPInstruction(Instruction::Mul, {I2, I1}); | ||
| VPInstruction *I5 = new VPInstruction(Instruction::Ret, {I4}); | ||
| VPInstruction *I5 = new VPInstruction(Instruction::Br, {I4}); | ||
|
Comment on lines
-725
to
+727
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid checking return with a single operand? A VPInstruction with an Instruction opcode should retain the latter's number of operands, but that may require checking an underlying Instruction?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, we currently never create VPInstruction for |
||
| VPBasicBlock *VPBB2 = Plan.createVPBasicBlock(""); | ||
| VPBB2->appendRecipe(I4); | ||
| VPBB2->appendRecipe(I5); | ||
|
|
@@ -752,22 +754,22 @@ edge [fontname=Courier, fontsize=30] | |
| compound=true | ||
| N0 [label = | ||
| "preheader:\l" + | ||
| " EMIT vp\<%1\> = add \l" + | ||
| " EMIT-SCALAR vp\<%1\> = phi \l" + | ||
| "Successor(s): bb1\l" | ||
| ] | ||
| N0 -> N1 [ label=""] | ||
| N1 [label = | ||
| "bb1:\l" + | ||
| " EMIT vp\<%2\> = add \l" + | ||
| " EMIT vp\<%3\> = sub vp\<%2\>\l" + | ||
| " EMIT vp\<%2\> = add ir\<1\>, ir\<1\>\l" + | ||
| " EMIT vp\<%3\> = sub vp\<%2\>, ir\<1\>\l" + | ||
| " EMIT br vp\<%2\>, vp\<%3\>\l" + | ||
| "Successor(s): bb2\l" | ||
| ] | ||
| N1 -> N2 [ label=""] | ||
| N2 [label = | ||
| "bb2:\l" + | ||
| " EMIT vp\<%5\> = mul vp\<%3\>, vp\<%2\>\l" + | ||
| " EMIT ret vp\<%5\>\l" + | ||
| " EMIT br vp\<%5\>\l" + | ||
| "Successor(s): ir-bb\<scalar.header\>\l" | ||
| ] | ||
| N2 -> N3 [ label=""] | ||
|
|
@@ -780,8 +782,8 @@ compound=true | |
| EXPECT_EQ(ExpectedStr, FullDump); | ||
|
|
||
| const char *ExpectedBlock1Str = R"(bb1: | ||
| EMIT vp<%2> = add | ||
| EMIT vp<%3> = sub vp<%2> | ||
| EMIT vp<%2> = add ir<1>, ir<1> | ||
| EMIT vp<%3> = sub vp<%2>, ir<1> | ||
| EMIT br vp<%2>, vp<%3> | ||
| Successor(s): bb2 | ||
| )"; | ||
|
|
@@ -793,7 +795,7 @@ Successor(s): bb2 | |
| // Ensure that numbering is good when dumping the second block in isolation. | ||
| const char *ExpectedBlock2Str = R"(bb2: | ||
| EMIT vp<%5> = mul vp<%3>, vp<%2> | ||
| EMIT ret vp<%5> | ||
| EMIT br vp<%5> | ||
| Successor(s): ir-bb<scalar.header> | ||
| )"; | ||
| std::string Block2Dump; | ||
|
|
@@ -909,9 +911,12 @@ TEST_F(VPBasicBlockTest, cloneAndPrint) { | |
| VPlan &Plan = getPlan(nullptr); | ||
| VPBasicBlock *VPBB0 = Plan.getEntry(); | ||
|
|
||
| VPInstruction *I1 = new VPInstruction(Instruction::Add, {}); | ||
| VPInstruction *I2 = new VPInstruction(Instruction::Sub, {I1}); | ||
| VPInstruction *I3 = new VPInstruction(Instruction::Br, {I1, I2}); | ||
| IntegerType *Int32 = IntegerType::get(C, 32); | ||
| VPValue *Val = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 1)); | ||
|
|
||
| VPInstruction *I1 = new VPInstruction(Instruction::Add, {Val, Val}); | ||
| VPInstruction *I2 = new VPInstruction(Instruction::Sub, {I1, Val}); | ||
| VPInstruction *I3 = new VPInstruction(Instruction::Store, {I1, I2}); | ||
|
|
||
| VPBasicBlock *VPBB1 = Plan.createVPBasicBlock(""); | ||
| VPBB1->appendRecipe(I1); | ||
|
|
@@ -932,9 +937,9 @@ compound=true | |
| N0 -> N1 [ label=""] | ||
| N1 [label = | ||
| "bb1:\l" + | ||
| " EMIT vp\<%1\> = add \l" + | ||
| " EMIT vp\<%2\> = sub vp\<%1\>\l" + | ||
| " EMIT br vp\<%1\>, vp\<%2\>\l" + | ||
| " EMIT vp\<%1\> = add ir\<1\>, ir\<1\>\l" + | ||
| " EMIT vp\<%2\> = sub vp\<%1\>, ir\<1\>\l" + | ||
| " EMIT store vp\<%1\>, vp\<%2\>\l" + | ||
| "No successors\l" | ||
| ] | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done thanks