1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S < %s | FileCheck %s
4 define noundef i32 @test_ret_noundef(i1 %cond) {
5 ; CHECK-LABEL: @test_ret_noundef(
7 ; CHECK-NEXT: ret i32 1
10 br i1 %cond, label %bb1, label %bb2
16 %r = phi i32 [ undef, %entry ], [ 1, %bb1 ]
20 define i32 @test_ret(i1 %cond) {
21 ; CHECK-LABEL: @test_ret(
23 ; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[COND:%.*]], i32 1, i32 undef
24 ; CHECK-NEXT: ret i32 [[SPEC_SELECT]]
27 br i1 %cond, label %bb1, label %bb2
33 %r = phi i32 [ undef, %entry ], [ 1, %bb1 ]
37 define nonnull noundef ptr @test_ret_ptr_nonnull_noundef(i1 %cond, ptr %x) {
38 ; CHECK-LABEL: @test_ret_ptr_nonnull_noundef(
40 ; CHECK-NEXT: call void @llvm.assume(i1 [[COND:%.*]])
41 ; CHECK-NEXT: ret ptr [[X:%.*]]
44 br i1 %cond, label %bb1, label %bb2
50 %r = phi ptr [ null, %entry ], [ %x, %bb1 ]
54 define nonnull noundef ptr @test_ret_ptr_nonnull_noundef_gep_nonzero(i1 %cond, ptr %x) {
55 ; CHECK-LABEL: @test_ret_ptr_nonnull_noundef_gep_nonzero(
57 ; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[COND:%.*]], ptr [[X:%.*]], ptr null
58 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr ptr, ptr [[SPEC_SELECT]], i64 12
59 ; CHECK-NEXT: ret ptr [[GEP]]
62 br i1 %cond, label %bb1, label %bb2
68 %phi = phi ptr [ null, %entry ], [ %x, %bb1 ]
69 %gep = getelementptr ptr, ptr %phi, i64 12
73 define nonnull noundef ptr @test_ret_ptr_nonnull_noundef_gep_inbounds_nonzero(i1 %cond, ptr %x) {
74 ; CHECK-LABEL: @test_ret_ptr_nonnull_noundef_gep_inbounds_nonzero(
76 ; CHECK-NEXT: call void @llvm.assume(i1 [[COND:%.*]])
77 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds ptr, ptr [[X:%.*]], i64 12
78 ; CHECK-NEXT: ret ptr [[GEP]]
81 br i1 %cond, label %bb1, label %bb2
87 %phi = phi ptr [ null, %entry ], [ %x, %bb1 ]
88 %gep = getelementptr inbounds ptr, ptr %phi, i64 12
92 define nonnull ptr @test_ret_ptr_nonnull(i1 %cond, ptr %x) {
93 ; CHECK-LABEL: @test_ret_ptr_nonnull(
95 ; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[COND:%.*]], ptr [[X:%.*]], ptr null
96 ; CHECK-NEXT: ret ptr [[SPEC_SELECT]]
99 br i1 %cond, label %bb1, label %bb2
105 %r = phi ptr [ null, %entry ], [ %x, %bb1 ]
109 define noundef ptr @test_ret_ptr_noundef(i1 %cond, ptr %x) {
110 ; CHECK-LABEL: @test_ret_ptr_noundef(
112 ; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[COND:%.*]], ptr [[X:%.*]], ptr null
113 ; CHECK-NEXT: ret ptr [[SPEC_SELECT]]
116 br i1 %cond, label %bb1, label %bb2
122 %r = phi ptr [ null, %entry ], [ %x, %bb1 ]
126 define ptr @test_ret_ptr(i1 %cond, ptr %x) {
127 ; CHECK-LABEL: @test_ret_ptr(
129 ; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[COND:%.*]], ptr [[X:%.*]], ptr null
130 ; CHECK-NEXT: ret ptr [[SPEC_SELECT]]
133 br i1 %cond, label %bb1, label %bb2
139 %r = phi ptr [ null, %entry ], [ %x, %bb1 ]