OSDN Git Service

[InstCombine] Add more tests to select-safe-transforms.ll (NFC)
authorJuneyoung Lee <aqjune@gmail.com>
Sat, 16 Jan 2021 10:49:12 +0000 (19:49 +0900)
committerJuneyoung Lee <aqjune@gmail.com>
Sat, 16 Jan 2021 10:49:12 +0000 (19:49 +0900)
llvm/test/Transforms/InstCombine/select-safe-transforms.ll

index 48067bf..b16985b 100644 (file)
@@ -14,6 +14,19 @@ define i1 @cond_eq_and(i8 %X, i8 %Y, i8 noundef %C) {
   ret i1 %res
 }
 
+define i1 @cond_eq_and_const(i8 %X, i8 %Y) {
+; CHECK-LABEL: @cond_eq_and_const(
+; CHECK-NEXT:    [[COND:%.*]] = icmp eq i8 [[X:%.*]], 10
+; CHECK-NEXT:    [[LHS:%.*]] = icmp ult i8 [[X]], [[Y:%.*]]
+; CHECK-NEXT:    [[RES:%.*]] = select i1 [[COND]], i1 [[LHS]], i1 false
+; CHECK-NEXT:    ret i1 [[RES]]
+;
+  %cond = icmp eq i8 %X, 10
+  %lhs = icmp ult i8 %X, %Y
+  %res = select i1 %cond, i1 %lhs, i1 false
+  ret i1 %res
+}
+
 define i1 @cond_eq_or(i8 %X, i8 %Y, i8 noundef %C) {
 ; CHECK-LABEL: @cond_eq_or(
 ; CHECK-NEXT:    [[COND:%.*]] = icmp ne i8 [[X:%.*]], [[C:%.*]]
@@ -27,6 +40,19 @@ define i1 @cond_eq_or(i8 %X, i8 %Y, i8 noundef %C) {
   ret i1 %res
 }
 
+define i1 @cond_eq_or_const(i8 %X, i8 %Y) {
+; CHECK-LABEL: @cond_eq_or_const(
+; CHECK-NEXT:    [[COND:%.*]] = icmp ne i8 [[X:%.*]], 10
+; CHECK-NEXT:    [[LHS:%.*]] = icmp ult i8 [[X]], [[Y:%.*]]
+; CHECK-NEXT:    [[RES:%.*]] = select i1 [[COND]], i1 true, i1 [[LHS]]
+; CHECK-NEXT:    ret i1 [[RES]]
+;
+  %cond = icmp ne i8 %X, 10
+  %lhs = icmp ult i8 %X, %Y
+  %res = select i1 %cond, i1 true, i1 %lhs
+  ret i1 %res
+}
+
 define i1 @merge_and(i1 %X, i1 %Y) {
 ; CHECK-LABEL: @merge_and(
 ; CHECK-NEXT:    [[C:%.*]] = select i1 [[X:%.*]], i1 [[Y:%.*]], i1 false