[llvm] [AArch64][InstCombine] Eliminate redundant barrier intrinsics (PR #112023)

Danila Malyutin via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 14 12:07:25 PDT 2024


================
@@ -2150,13 +2150,42 @@ static std::optional<Instruction *> instCombineSVEInsr(InstCombiner &IC,
   return std::nullopt;
 }
 
+static std::optional<Instruction *> instCombineDMB(InstCombiner &IC,
+                                                   IntrinsicInst &II) {
+  // If this barrier is post-dominated by identical one we can remove it
+  auto *NI = II.getNextNonDebugInstruction();
+  int LookaheadThreshold = 10;
+  auto CanSkipOver = [](Instruction *I) {
+    return !I->mayReadOrWriteMemory() && !I->mayHaveSideEffects();
----------------
danilaml wrote:

`willreturn` should be handled by side effects check, IIUC:
```cpp
bool Instruction::mayHaveSideEffects() const {
  return mayWriteToMemory() || mayThrow() || !willReturn();
}
```

https://github.com/llvm/llvm-project/pull/112023


More information about the llvm-commits mailing list