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

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


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

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

>From 2ba5b8afaa22a138b0860140601b0a3c10c7e7a4 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 | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 6ad493772d170..896548ddd9931 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -3412,6 +3412,9 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
             !isPowerOf2_64(RK.ArgValue) || !isa<ConstantInt>(RK.IRArgValue))
           continue;
 
+        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