[llvm] 3b8cfef - [InstCombine] Add more tests to nonnull-select.ll (NFC)

Juneyoung Lee via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 20 00:00:10 PST 2021


Author: Juneyoung Lee
Date: 2021-02-20T16:59:52+09:00
New Revision: 3b8cfef4860adc0ffc984db258604851604ca4ff

URL: https://github.com/llvm/llvm-project/commit/3b8cfef4860adc0ffc984db258604851604ca4ff
DIFF: https://github.com/llvm/llvm-project/commit/3b8cfef4860adc0ffc984db258604851604ca4ff.diff

LOG: [InstCombine] Add more tests to nonnull-select.ll (NFC)

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/nonnull-select.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/nonnull-select.ll b/llvm/test/Transforms/InstCombine/nonnull-select.ll
index 2fc7df2f25d4..2e44d024fad7 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*)


        


More information about the llvm-commits mailing list