Skip to content

Conversation

fhahn
Copy link
Contributor

@fhahn fhahn commented Sep 25, 2025

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

@llvmbot llvmbot added llvm:instcombine Covers the InstCombine, InstSimplify and AggressiveInstCombine passes llvm:transforms labels Sep 25, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 25, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Florian Hahn (fhahn)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/160695.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp (+3)
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.

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
@fhahn fhahn force-pushed the ic-remove-assume-align-1 branch from 2ba5b8a to 861c9a7 Compare September 25, 2025 12:24
Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing test?

@fhahn
Copy link
Contributor Author

fhahn commented Sep 25, 2025

Missing test?

Woops stripped the update by accident. Should be back now

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


// Remove align 1 bundles; they don't add any useful information.
if (RK.ArgValue == 1)
return CallBase::removeOperandBundle(II, OBU.getTagID());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note (as this is not the only place with this problem), but this API doesn't do the right thing if there are multiple assume operand bundles with the same name. No idea whether that's supposed to be allowed or only permitted by accident.

@fhahn fhahn merged commit d45a135 into llvm:main Sep 25, 2025
9 checks passed
@fhahn fhahn deleted the ic-remove-assume-align-1 branch September 25, 2025 17:00
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Sep 25, 2025
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

PR: llvm/llvm-project#160695
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Oct 3, 2025
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

PR: llvm#160695
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llvm:instcombine Covers the InstCombine, InstSimplify and AggressiveInstCombine passes llvm:transforms

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants