llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.26k stars 12.09k forks source link

[DSE] Missed optimization #115341

Open omern1 opened 2 weeks ago

omern1 commented 2 weeks ago
; Build with opt --passes='dse' -debug

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z9eaot_testv() {
  store i32 3267512, ptr inttoptr (i64 68719476864 to ptr), align 4
  %1 = load i32, ptr inttoptr (i64 68719476812 to ptr), align 4
  store i32 %1, ptr inttoptr (i64 137438953472 to ptr), align 4
  store i32 3267516, ptr inttoptr (i64 68719476864 to ptr), align 4
  ret void
}

The first store and the load %1 don't actually alias but DSE fails to delete redundant stores (first and last).

nikic commented 2 weeks ago

This is an AA problem. We currently don't really have any alias analysis support for inttoptr, even for obvious cases like this.