[llvm] [InstCombine] Remove redundant align 1 assumptions. (PR #160695)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 25 05:58:46 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 1/2] [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.
>From f2126d5c8020564657fdc5a24445ae4748dfe113 Mon Sep 17 00:00:00 2001
From: Florian Hahn <flo at fhahn.com>
Date: Thu, 25 Sep 2025 13:54:25 +0100
Subject: [PATCH 2/2] !fixup update test
---
llvm/test/Transforms/InstCombine/assume-align.ll | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/llvm/test/Transforms/InstCombine/assume-align.ll b/llvm/test/Transforms/InstCombine/assume-align.ll
index f6373d85ddb9c..4185b10eeca95 100644
--- a/llvm/test/Transforms/InstCombine/assume-align.ll
+++ b/llvm/test/Transforms/InstCombine/assume-align.ll
@@ -249,8 +249,7 @@ define ptr @redundant_assume_align_8_via_asume(ptr %p) {
define ptr @assume_align_1(ptr %p) {
; CHECK-LABEL: @assume_align_1(
-; CHECK-NEXT: call void @llvm.assume(i1 true) [ "align"(ptr [[P:%.*]], i32 1) ]
-; CHECK-NEXT: call void @foo(ptr [[P]])
+; CHECK-NEXT: call void @foo(ptr [[P:%.*]])
; CHECK-NEXT: ret ptr [[P]]
;
call void @llvm.assume(i1 true) [ "align"(ptr %p, i32 1) ]
More information about the llvm-commits
mailing list