[llvm] [InstCombine] Remove redundant align 1 assumptions. (PR #160695)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 25 05:25:02 PDT 2025


https://github.com/fhahn updated https://github.com/llvm/llvm-project/pull/160695

>From 861c9a7f2593867e02dd85eb24c31ec7c07e3802 Mon Sep 17 00:00:00 2001
From: Florian Hahn <flo at fhahn.com>
Date: Thu, 25 Sep 2025 13:22:59 +0100
Subject: [PATCH] [InstCombine] Remove redundant align 1 assumptions.

It seems like we have a bunch of align 1 assumptions in practice and
unless I am missing something they should not add any value.

See https://github.com/dtcxzyw/llvm-opt-benchmark/pull/2861/files
---
 llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 6ad493772d170..04f787aae11aa 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -3412,6 +3412,10 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
             !isPowerOf2_64(RK.ArgValue) || !isa<ConstantInt>(RK.IRArgValue))
           continue;
 
+        // Remove align 1 bundles; they don't add any useful information.
+        if (RK.ArgValue == 1)
+          return CallBase::removeOperandBundle(II, OBU.getTagID());
+
         // Don't try to remove align assumptions for pointers derived from
         // arguments. We might lose information if the function gets inline and
         // the align argument attribute disappears.



More information about the llvm-commits mailing list