Skip to content

Failure to remove redundant assume given alignment on call #25442

@preames

Description

@preames
Bugzilla Link 25068
Version trunk
OS Linux
CC @hfinkel

Extended Description

This assume in the following test case should be removable.

target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

declare align 8 i8* @get()

; Function Attrs: nounwind
declare void @llvm.assume(i1) #0

define void @test() {
  %p = tail call align 8 i8* @get()
  %ptrint = ptrtoint i8* %p to i64
  %maskedptr = and i64 %ptrint, 7
  %maskcond = icmp eq i64 %maskedptr, 0
  tail call void @llvm.assume(i1 %maskcond)
  ret void
}

I believe the problem is that ValueTracking hasn't been taught that the low bits of an aligned pointer result are known to be zero.

Note that this example is particularly problematic since the inliner will introduce @​llvm.assume calls with this pattern. I haven't caught it producing something quite this trivial, but I have seen cases where the IR simplifies to something this simple.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillallvm:analysisIncludes value tracking, cost tables and constant folding

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions