[PATCH] D105392: [InstCombine] Add optimization to prevent poison from being propagated.

Hyeongyu Kim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 4 15:35:21 PDT 2021


hyeongyukim added a comment.

In D105392#2857277 <https://reviews.llvm.org/D105392#2857277>, @nikic wrote:

> Can you please add a test for freeze of phi? I expect this will fail because you can't insert an instruction before a phi. It's okay to simply bail on this case for now.



  define i32 @test(i1 %cond, i32 *%ptrA) {
  ; CHECK-LABEL: @test(
  ; CHECK-NEXT:    br i1 [[COND:%.*]], label [[A:%.*]], label [[B:%.*]]
  ; CHECK:       A:
  ; CHECK-NEXT:    br label [[C:%.*]]
  ; CHECK:       B:
  ; CHECK-NEXT:    [[V:%.*]] = load i32, i32* [[PTR:%.*]], align 4
  ; CHECK-NEXT:    [[PHI_FR:%.*]] = freeze i32 [[V]]
  ; CHECK-NEXT:    br label [[C]]
  ; CHECK:       C:
  ; CHECK-NEXT:    [[Y:%.*]] = phi i32 [ 0, [[A]] ], [ [[PHI_FR]], [[B]] ]
  ; CHECK-NEXT:    ret i32 [[Y]]
  ;
    br i1 %cond, label %A, label %B
  A:
    br label %C
  B:
    %v = load i32, i32* %ptr
    br label %C
  C:
    %y = phi i32 [0, %A], [%v, %B]
    %y.fr = freeze i32 %y
    ret i32 %y.fr
  }

I tried it, and it seems to go to the label included in phi and add freeze.
@nikic  Can you give me another example that could fail?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105392



More information about the llvm-commits mailing list