Skip to content

Comparison of object against addrspacecasted null pointer are not optimized out  #58617

Open
@arsenm

Description

@arsenm

I recently saw a test case where a conditional branch was left behind that should be trivially optimized out. A constant addrspacecast from a generic null pointer is compared to a valid object:

@lds = linkonce_odr hidden addrspace(3) global [128 x i32] undef, align 16

define void @foo() {
bb0:
  br i1 icmp eq ([128 x i32] addrspace(3)* addrspacecast ([128 x i32]* null to [128 x i32] addrspace(3)*), [128 x i32] addrspace(3)* @lds), label %bb1, label %bb2

bb1:
  store volatile i32 0, i32 addrspace(1)* null
  ret void

bb2:
  ret void
}

opt -O3 leaves behind this branch, which should trivially fold to false

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions