llvm/llvm/test/Transforms/CanonicalizeFreezeInLoops/duplicate_remove.ll

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
; RUN: opt < %s --passes=canon-freeze -S | FileCheck %s

define void @check_duplicate_removal(i32 %n) {
; CHECK-LABEL: define void @check_duplicate_removal(
; CHECK-SAME: i32 [[N:%.*]]) {
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[N_FROZEN:%.*]] = freeze i32 [[N]]
; CHECK-NEXT:    br label [[LOOP:%.*]]
; CHECK:       loop:
; CHECK-NEXT:    [[T1:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[T3:%.*]], [[LOOP]] ]
; CHECK-NEXT:    [[T2:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[T3]], [[LOOP]] ]
; CHECK-NEXT:    [[T3]] = add i32 [[N_FROZEN]], [[T2]]
; CHECK-NEXT:    [[COND:%.*]] = icmp eq i32 [[T2]], 0
; CHECK-NEXT:    br i1 [[COND]], label [[LOOP]], label [[EXIT:%.*]]
; CHECK:       exit:
; CHECK-NEXT:    ret void
;
entry:
  br label %loop

loop:
  %t1 = phi i32 [ 0, %entry], [%t3, %loop ]
  %t2 = phi i32 [ 0, %entry], [%t3, %loop ]
  %t3 = add i32 %n, %t2
  %.fr = freeze i32 %t3
  %cond = icmp eq i32 %t2, 0
  br i1 %cond, label %loop, label %exit

exit:
  ret void
}