1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=licm < %s | FileCheck %s
4 ; Make sure that a store of a pointer to itself is handled correctly.
6 define void @test(ptr %p1, ptr %p2, ptr noalias %p3) {
9 ; CHECK-NEXT: br label [[LOOP:%.*]]
11 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[P1:%.*]], [[ENTRY:%.*]] ], [ [[P2:%.*]], [[LOOP]] ]
12 ; CHECK-NEXT: [[V:%.*]] = load i64, ptr [[P]], align 4
13 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[V]], 0
14 ; CHECK-NEXT: br i1 [[CMP]], label [[LOOP]], label [[LOOP_EXIT:%.*]]
16 ; CHECK-NEXT: store ptr [[P3:%.*]], ptr [[P3]], align 8
17 ; CHECK-NEXT: ret void
23 %p = phi ptr [ %p1, %entry ], [ %p2, %loop ]
25 %cmp = icmp eq i64 %v, 0
26 store ptr %p3, ptr %p3
27 br i1 %cmp, label %loop, label %loop.exit