; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals --version 2
; RUN: opt -S -passes=gvn-hoist < %s | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define void @test1(i1 %b, ptr %x) {
; CHECK-LABEL: define void @test1
; CHECK-SAME: (i1 [[B:%.*]], ptr [[X:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: store i32 2, ptr [[X]], align 4, !tbaa [[TBAA0:![0-9]+]]
; CHECK-NEXT: br i1 [[B]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
; CHECK: if.then:
; CHECK-NEXT: br label [[IF_END:%.*]]
; CHECK: if.else:
; CHECK-NEXT: br label [[IF_END]]
; CHECK: if.end:
; CHECK-NEXT: ret void
;
entry:
br i1 %b, label %if.then, label %if.else
if.then: ; preds = %entry
store i32 2, ptr %x, align 4, !tbaa !1
br label %if.end
if.else: ; preds = %entry
store i32 2, ptr %x, align 4, !tbaa !5
br label %if.end
if.end: ; preds = %if.else, %if.then
ret void
}
define void @test2(i1 %b, ptr %x) {
; CHECK-LABEL: define void @test2
; CHECK-SAME: (i1 [[B:%.*]], ptr [[X:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 1
; CHECK-NEXT: store i32 2, ptr [[TMP0]], align 4, !tbaa [[TBAA0]]
; CHECK-NEXT: br i1 [[B]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
; CHECK: if.then:
; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 1
; CHECK-NEXT: br label [[IF_END:%.*]]
; CHECK: if.else:
; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 1
; CHECK-NEXT: br label [[IF_END]]
; CHECK: if.end:
; CHECK-NEXT: ret void
;
entry:
br i1 %b, label %if.then, label %if.else
if.then: ; preds = %entry
%gep1 = getelementptr inbounds i32, ptr %x, i64 1
store i32 2, ptr %gep1, align 4, !tbaa !1
br label %if.end
if.else: ; preds = %entry
%gep2 = getelementptr inbounds i32, ptr %x, i64 1
store i32 2, ptr %gep2, align 4, !tbaa !5
br label %if.end
if.end: ; preds = %if.else, %if.then
ret void
}
define void @test3(i1 %b, ptr %x) {
; CHECK-LABEL: define void @test3
; CHECK-SAME: (i1 [[B:%.*]], ptr [[X:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP0:%.*]] = getelementptr i32, ptr [[X]], i64 1
; CHECK-NEXT: store i32 2, ptr [[TMP0]], align 4, !tbaa [[TBAA0]]
; CHECK-NEXT: br i1 [[B]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
; CHECK: if.then:
; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 1
; CHECK-NEXT: br label [[IF_END:%.*]]
; CHECK: if.else:
; CHECK-NEXT: [[GEP2:%.*]] = getelementptr i32, ptr [[X]], i64 1
; CHECK-NEXT: br label [[IF_END]]
; CHECK: if.end:
; CHECK-NEXT: ret void
;
entry:
br i1 %b, label %if.then, label %if.else
if.then: ; preds = %entry
%gep1 = getelementptr inbounds i32, ptr %x, i64 1
store i32 2, ptr %gep1, align 4, !tbaa !1
br label %if.end
if.else: ; preds = %entry
%gep2 = getelementptr i32, ptr %x, i64 1
store i32 2, ptr %gep2, align 4, !tbaa !5
br label %if.end
if.end: ; preds = %if.else, %if.then
ret void
}
define i32 @test4(i1 %b, ptr %y) {
; CHECK-LABEL: define i32 @test4
; CHECK-SAME: (i1 [[B:%.*]], ptr [[Y:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[Y]], align 4, !range [[RNG3:![0-9]+]]
; CHECK-NEXT: br i1 [[B]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
; CHECK: if.then:
; CHECK-NEXT: br label [[RETURN:%.*]]
; CHECK: if.end:
; CHECK-NEXT: br label [[RETURN]]
; CHECK: return:
; CHECK-NEXT: [[RETVAL_0:%.*]] = phi i32 [ [[TMP0]], [[IF_THEN]] ], [ [[TMP0]], [[IF_END]] ]
; CHECK-NEXT: ret i32 [[RETVAL_0]]
;
entry:
br i1 %b, label %if.then, label %if.end
if.then: ; preds = %entry
%0 = load i32, ptr %y, align 4, !range !7
br label %return
if.end: ; preds = %entry
%1 = load i32, ptr %y, align 4, !range !8
br label %return
return: ; preds = %if.end, %if.then
%retval.0 = phi i32 [ %0, %if.then ], [ %1, %if.end ]
ret i32 %retval.0
}
define ptr @test5(i1 %b, ptr %y) {
; CHECK-LABEL: define ptr @test5
; CHECK-SAME: (i1 [[B:%.*]], ptr [[Y:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[Y]], align 4
; CHECK-NEXT: br i1 [[B]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
; CHECK: if.then:
; CHECK-NEXT: br label [[RETURN:%.*]]
; CHECK: if.end:
; CHECK-NEXT: br label [[RETURN]]
; CHECK: return:
; CHECK-NEXT: [[RETVAL_0:%.*]] = phi ptr [ [[TMP0]], [[IF_THEN]] ], [ [[TMP0]], [[IF_END]] ]
; CHECK-NEXT: ret ptr [[RETVAL_0]]
;
entry:
br i1 %b, label %if.then, label %if.end
if.then: ; preds = %entry
%0 = load ptr, ptr %y, align 4, !nonnull !9
br label %return
if.end: ; preds = %entry
%1 = load ptr, ptr %y, align 4
br label %return
return: ; preds = %if.end, %if.then
%retval.0 = phi ptr [ %0, %if.then ], [ %1, %if.end ]
ret ptr %retval.0
}
!1 = !{!2, !2, i64 0}
!2 = !{!"int", !3, i64 0}
!3 = !{!"omnipotent char", !4, i64 0}
!4 = !{!"Simple C++ TBAA"}
!5 = !{!6, !6, i64 0}
!6 = !{!"_ZTS1e", !3, i64 0}
!7 = !{i32 0, i32 2}
!8 = !{i32 3, i32 4}
!9 = !{}
;.
; CHECK: [[TBAA0]] = !{!1, !1, i64 0}
; CHECK: [[META1:![0-9]+]] = !{!"omnipotent char", !2, i64 0}
; CHECK: [[META2:![0-9]+]] = !{!"Simple C++ TBAA"}
; CHECK: [[RNG3]] = !{i32 0, i32 2, i32 3, i32 4}
;.