mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-03-03 08:02:41 +00:00
[GISel: Add support for CSEing SrcOps which are immediates
https://reviews.llvm.org/D84072 Add G_EXTRACT to CSEConfigFull and add unit test as well.
This commit is contained in:
parent
cf5df40c4c
commit
63c081e73d
@ -59,6 +59,7 @@ bool CSEConfigFull::shouldCSEOpc(unsigned Opc) {
|
||||
case TargetOpcode::G_UNMERGE_VALUES:
|
||||
case TargetOpcode::G_TRUNC:
|
||||
case TargetOpcode::G_PTR_ADD:
|
||||
case TargetOpcode::G_EXTRACT:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -70,6 +70,9 @@ void CSEMIRBuilder::profileDstOp(const DstOp &Op,
|
||||
void CSEMIRBuilder::profileSrcOp(const SrcOp &Op,
|
||||
GISelInstProfileBuilder &B) const {
|
||||
switch (Op.getSrcOpKind()) {
|
||||
case SrcOp::SrcType::Ty_Imm:
|
||||
B.addNodeIDImmediate(static_cast<int64_t>(Op.getImm()));
|
||||
break;
|
||||
case SrcOp::SrcType::Ty_Predicate:
|
||||
B.addNodeIDImmediate(static_cast<int64_t>(Op.getPredicate()));
|
||||
break;
|
||||
|
@ -96,6 +96,15 @@ TEST_F(AArch64GISelMITest, TestCSE) {
|
||||
auto CSEFMul =
|
||||
CSEB.buildInstr(TargetOpcode::G_AND, {s32}, {Copies[0], Copies[1]});
|
||||
EXPECT_EQ(&*CSEFMul, &*NonCSEFMul);
|
||||
|
||||
auto ExtractMIB = CSEB.buildInstr(TargetOpcode::G_EXTRACT, {s16},
|
||||
{Copies[0], static_cast<uint64_t>(0)});
|
||||
auto ExtractMIB1 = CSEB.buildInstr(TargetOpcode::G_EXTRACT, {s16},
|
||||
{Copies[0], static_cast<uint64_t>(0)});
|
||||
auto ExtractMIB2 = CSEB.buildInstr(TargetOpcode::G_EXTRACT, {s16},
|
||||
{Copies[0], static_cast<uint64_t>(1)});
|
||||
EXPECT_EQ(&*ExtractMIB, &*ExtractMIB1);
|
||||
EXPECT_NE(&*ExtractMIB, &*ExtractMIB2);
|
||||
}
|
||||
|
||||
TEST_F(AArch64GISelMITest, TestCSEConstantConfig) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user