[PATCH] D84181: [GVN] Rewrite IsValueFullyAvailableInBlock()

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 24 09:22:37 PDT 2020


fhahn added a comment.

In D84181#2171662 <https://reviews.llvm.org/D84181#2171662>, @lebedev.ri wrote:

> @fhahn thanks for taking a look!
>  Indeed, the test is bad.


Perhaps the problem was a missing read none on the use calls?

E.g. something like the following seems to work as expected. Might still be possible to remove some parts of the cfg.

  define i32 @loadpre_opportunity(i32** %arg, i1 %arg1, i1 %arg2, i1 %arg3) {
  bb:
    %i = load i32*, i32** %arg, align 8
    %i4 = getelementptr inbounds i32, i32* %i, i64 0
    br label %bb5
  
  bb5:
    %v.1 = call i32 @use(i32* %i4)
    br label %bb9
  
  bb6:
    %i7 = load i32*, i32** %arg, align 8
    %i8 = getelementptr inbounds i32, i32* %i7, i64 0
    %v.2 = call i32 @use(i32* %i8)
    br label %bb9
  
  bb9:
    %p = phi i32 [ %v.1, %bb5 ], [ %v.2, %bb6]
    br i1 %arg1, label %bb6, label %bb10
  
  bb10:
    call void @somecall()
    br i1 %arg2, label %bb12, label %bb15
  
  bb12:
    br label %bb13
  
  bb13:
    br i1 %arg3, label %bb14, label %bb13
  
  bb14:
    br label %bb15
  
  bb15:
    %c = call i1 @cond()
    br i1 %c, label %bb6, label %exit
  
  exit:
    ret i32 %p
  }
  
  declare void @somecall()
  declare i32 @use(i32*) readnone
  declare i1 @cond() readnone


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84181/new/

https://reviews.llvm.org/D84181





More information about the llvm-commits mailing list