From 3b8cfef4860adc0ffc984db258604851604ca4ff Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Sat, 20 Feb 2021 16:59:52 +0900 Subject: [PATCH] [InstCombine] Add more tests to nonnull-select.ll (NFC) --- llvm/test/Transforms/InstCombine/nonnull-select.ll | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/llvm/test/Transforms/InstCombine/nonnull-select.ll b/llvm/test/Transforms/InstCombine/nonnull-select.ll index 2fc7df2..2e44d02 100644 --- a/llvm/test/Transforms/InstCombine/nonnull-select.ll +++ b/llvm/test/Transforms/InstCombine/nonnull-select.ll @@ -27,8 +27,47 @@ define nonnull i32* @nonnull_ret(i1 %cond, i32* %p) { ret i32* %res } +define nonnull i32* @nonnull_ret2(i1 %cond, i32* %p) { +; CHECK-LABEL: @nonnull_ret2( +; CHECK-NEXT: [[RES:%.*]] = select i1 [[COND:%.*]], i32* null, i32* [[P:%.*]] +; CHECK-NEXT: ret i32* [[RES]] +; + %res = select i1 %cond, i32* null, i32* %p + ret i32* %res +} + +define nonnull noundef i32* @nonnull_noundef_ret(i1 %cond, i32* %p) { +; CHECK-LABEL: @nonnull_noundef_ret( +; CHECK-NEXT: [[RES:%.*]] = select i1 [[COND:%.*]], i32* [[P:%.*]], i32* null +; CHECK-NEXT: ret i32* [[RES]] +; + %res = select i1 %cond, i32* %p, i32* null + ret i32* %res +} + +define nonnull noundef i32* @nonnull_noundef_ret2(i1 %cond, i32* %p) { +; CHECK-LABEL: @nonnull_noundef_ret2( +; CHECK-NEXT: [[RES:%.*]] = select i1 [[COND:%.*]], i32* null, i32* [[P:%.*]] +; CHECK-NEXT: ret i32* [[RES]] +; + %res = select i1 %cond, i32* null, i32* %p + ret i32* %res +} + + define void @nonnull_call(i1 %cond, i32* %p) { ; CHECK-LABEL: @nonnull_call( +; CHECK-NEXT: [[RES:%.*]] = select i1 [[COND:%.*]], i32* [[P:%.*]], i32* null +; CHECK-NEXT: call void @f(i32* nonnull [[RES]]) +; CHECK-NEXT: ret void +; + %res = select i1 %cond, i32* %p, i32* null + call void @f(i32* nonnull %res) + ret void +} + +define void @nonnull_call2(i1 %cond, i32* %p) { +; CHECK-LABEL: @nonnull_call2( ; CHECK-NEXT: [[RES:%.*]] = select i1 [[COND:%.*]], i32* null, i32* [[P:%.*]] ; CHECK-NEXT: call void @f(i32* nonnull [[RES]]) ; CHECK-NEXT: ret void @@ -38,4 +77,26 @@ define void @nonnull_call(i1 %cond, i32* %p) { ret void } +define void @nonnull_noundef_call(i1 %cond, i32* %p) { +; CHECK-LABEL: @nonnull_noundef_call( +; CHECK-NEXT: [[RES:%.*]] = select i1 [[COND:%.*]], i32* [[P:%.*]], i32* null +; CHECK-NEXT: call void @f(i32* noundef nonnull [[RES]]) +; CHECK-NEXT: ret void +; + %res = select i1 %cond, i32* %p, i32* null + call void @f(i32* nonnull noundef %res) + ret void +} + +define void @nonnull_noundef_call2(i1 %cond, i32* %p) { +; CHECK-LABEL: @nonnull_noundef_call2( +; CHECK-NEXT: [[RES:%.*]] = select i1 [[COND:%.*]], i32* null, i32* [[P:%.*]] +; CHECK-NEXT: call void @f(i32* noundef nonnull [[RES]]) +; CHECK-NEXT: ret void +; + %res = select i1 %cond, i32* null, i32* %p + call void @f(i32* nonnull noundef %res) + ret void +} + declare void @f(i32*) -- 2.7.4