; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
; RUN: opt -S -passes=newgvn %s | FileCheck %s
@a = external global i32, align 4
@patatino = external unnamed_addr constant [2 x i8], align 1
define void @tinkywinky() {
; CHECK-LABEL: define void @tinkywinky() {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[D:%.*]] = alloca i32, align 4
; CHECK-NEXT: store i32 0, ptr null, align 4
; CHECK-NEXT: br label [[FOR_COND:%.*]]
; CHECK: for.cond:
; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr null, align 4
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[TMP0]], 1
; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[WHILE_COND:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr @a, align 4
; CHECK-NEXT: store i32 [[TMP1]], ptr [[D]], align 4
; CHECK-NEXT: br label [[L:%.*]]
; CHECK: L:
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[TMP1]], 0
; CHECK-NEXT: br i1 [[TOBOOL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
; CHECK: if.then:
; CHECK-NEXT: call void (ptr, ...) @printf(ptr @patatino)
; CHECK-NEXT: br label [[L]]
; CHECK: if.end:
; CHECK-NEXT: br label [[FOR_COND]]
; CHECK: while.cond:
; CHECK-NEXT: br i1 undef, label [[WHILE_BODY:%.*]], label [[WHILE_END:%.*]]
; CHECK: while.body:
; CHECK-NEXT: call void (ptr, ...) @printf(ptr @patatino)
; CHECK-NEXT: br label [[WHILE_COND]]
; CHECK: while.end:
; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr @a, align 4
; CHECK-NEXT: store i32 [[TMP2]], ptr undef, align 4
; CHECK-NEXT: ret void
;
entry:
%d = alloca i32, align 4
store i32 0, ptr null, align 4
br label %for.cond
for.cond:
%0 = load i32, ptr null, align 4
%cmp = icmp slt i32 %0, 1
br i1 %cmp, label %for.body, label %while.cond
for.body:
%1 = load i32, ptr @a, align 4
store i32 %1, ptr %d, align 4
br label %L
L:
%2 = load i32, ptr %d, align 4
%tobool = icmp ne i32 %2, 0
br i1 %tobool, label %if.then, label %if.end
if.then:
call void (ptr, ...) @printf(ptr @patatino)
br label %L
if.end:
br label %for.cond
while.cond:
br i1 undef, label %while.body, label %while.end
while.body:
call void (ptr, ...) @printf(ptr @patatino)
br label %while.cond
while.end:
%3 = load i32, ptr @a, align 4
store i32 %3, ptr undef, align 4
ret void
}
declare void @printf(ptr, ...) #1