[llvm] [CodeGenPrepare] Resolve TODO: Treat disjoint-or as an add (PR #88667)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 14 15:17:40 PDT 2024
https://github.com/AtariDreams updated https://github.com/llvm/llvm-project/pull/88667
>From 93eaab9300a947df86edce630ae1c83f34956ade Mon Sep 17 00:00:00 2001
From: Rose <gfunni234 at gmail.com>
Date: Sun, 14 Apr 2024 12:31:10 -0400
Subject: [PATCH] [CodeGenPrepare] Resolve TODO: Treat disjoint-or as an add
Because we can treat Or-disjoint as an add, this allows for better codegen preparation.
---
llvm/lib/CodeGen/CodeGenPrepare.cpp | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 22dbb3198a9f17..64faa4d018578c 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -4339,6 +4339,8 @@ static bool MightBeFoldableInst(Instruction *I) {
case Instruction::IntToPtr:
// We know the input is intptr_t, so this is foldable.
return true;
+ case Instruction::Or:
+ return cast<PossiblyDisjointInst>(I)->isDisjoint();
case Instruction::Add:
return true;
case Instruction::Mul:
@@ -4851,6 +4853,11 @@ bool AddressingModeMatcher::matchOperationAddr(User *AddrInst, unsigned Opcode,
return matchAddr(AddrInst->getOperand(0), Depth);
return false;
}
+ case Instruction::Or:
+ // We can handle OR iff it can be treated as an add.
+ if (!cast<PossiblyDisjointInst>(AddrInst)->isDisjoint())
+ break;
+ [[fallthrough]];
case Instruction::Add: {
// Check to see if we can merge in one operand, then the other. If so, we
// win.
@@ -4891,9 +4898,6 @@ bool AddressingModeMatcher::matchOperationAddr(User *AddrInst, unsigned Opcode,
TPT.rollback(LastKnownGood);
break;
}
- // case Instruction::Or:
- // TODO: We can handle "Or Val, Imm" iff this OR is equivalent to an ADD.
- // break;
case Instruction::Mul:
case Instruction::Shl: {
// Can only handle X*C and X << C.
More information about the llvm-commits
mailing list