Skip to content

Commit d45a135

Browse files
authored
[InstCombine] Remove redundant align 1 assumptions. (#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 PR: #160695
1 parent 0f1a952 commit d45a135

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3412,6 +3412,10 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
34123412
!isPowerOf2_64(RK.ArgValue) || !isa<ConstantInt>(RK.IRArgValue))
34133413
continue;
34143414

3415+
// Remove align 1 bundles; they don't add any useful information.
3416+
if (RK.ArgValue == 1)
3417+
return CallBase::removeOperandBundle(II, OBU.getTagID());
3418+
34153419
// Don't try to remove align assumptions for pointers derived from
34163420
// arguments. We might lose information if the function gets inline and
34173421
// the align argument attribute disappears.

llvm/test/Transforms/InstCombine/assume-align.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,7 @@ define ptr @redundant_assume_align_8_via_asume(ptr %p) {
249249

250250
define ptr @assume_align_1(ptr %p) {
251251
; CHECK-LABEL: @assume_align_1(
252-
; CHECK-NEXT: call void @llvm.assume(i1 true) [ "align"(ptr [[P:%.*]], i32 1) ]
253-
; CHECK-NEXT: call void @foo(ptr [[P]])
252+
; CHECK-NEXT: call void @foo(ptr [[P:%.*]])
254253
; CHECK-NEXT: ret ptr [[P]]
255254
;
256255
call void @llvm.assume(i1 true) [ "align"(ptr %p, i32 1) ]

0 commit comments

Comments
 (0)