diff --git a/test/Transforms/InstCombine/icmp-dom.ll b/test/Transforms/InstCombine/icmp-dom.ll index 6441dd469c1..0ee2e258bcf 100644 --- a/test/Transforms/InstCombine/icmp-dom.ll +++ b/test/Transforms/InstCombine/icmp-dom.ll @@ -160,3 +160,171 @@ return: ret void } +define i1 @trueblock_cmp_is_false(i32 %x, i32 %y) { +; CHECK-LABEL: @trueblock_cmp_is_false( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]] +; CHECK: t: +; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[X]], [[Y]] +; CHECK-NEXT: ret i1 [[CMP2]] +; CHECK: f: +; CHECK-NEXT: ret i1 [[CMP]] +; +entry: + %cmp = icmp sgt i32 %x, %y + br i1 %cmp, label %t, label %f +t: + %cmp2 = icmp slt i32 %x, %y + ret i1 %cmp2 +f: + ret i1 %cmp +} + +define i1 @trueblock_cmp_is_false_commute(i32 %x, i32 %y) { +; CHECK-LABEL: @trueblock_cmp_is_false_commute( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]] +; CHECK: t: +; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i32 [[Y]], [[X]] +; CHECK-NEXT: ret i1 [[CMP2]] +; CHECK: f: +; CHECK-NEXT: ret i1 [[CMP]] +; +entry: + %cmp = icmp eq i32 %x, %y + br i1 %cmp, label %t, label %f +t: + %cmp2 = icmp sgt i32 %y, %x + ret i1 %cmp2 +f: + ret i1 %cmp +} + +define i1 @trueblock_cmp_is_true(i32 %x, i32 %y) { +; CHECK-LABEL: @trueblock_cmp_is_true( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]] +; CHECK: t: +; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i32 [[X]], [[Y]] +; CHECK-NEXT: ret i1 [[CMP2]] +; CHECK: f: +; CHECK-NEXT: ret i1 [[CMP]] +; +entry: + %cmp = icmp ult i32 %x, %y + br i1 %cmp, label %t, label %f +t: + %cmp2 = icmp ne i32 %x, %y + ret i1 %cmp2 +f: + ret i1 %cmp +} + +define i1 @trueblock_cmp_is_true_commute(i32 %x, i32 %y) { +; CHECK-LABEL: @trueblock_cmp_is_true_commute( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]] +; CHECK: t: +; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i32 [[Y]], [[X]] +; CHECK-NEXT: ret i1 [[CMP2]] +; CHECK: f: +; CHECK-NEXT: ret i1 [[CMP]] +; +entry: + %cmp = icmp ugt i32 %x, %y + br i1 %cmp, label %t, label %f +t: + %cmp2 = icmp ne i32 %y, %x + ret i1 %cmp2 +f: + ret i1 %cmp +} + +define i1 @falseblock_cmp_is_false(i32 %x, i32 %y) { +; CHECK-LABEL: @falseblock_cmp_is_false( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[CMP:%.*]] = icmp sle i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]] +; CHECK: t: +; CHECK-NEXT: ret i1 [[CMP]] +; CHECK: f: +; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[X]], [[Y]] +; CHECK-NEXT: ret i1 [[CMP2]] +; +entry: + %cmp = icmp sle i32 %x, %y + br i1 %cmp, label %t, label %f +t: + ret i1 %cmp +f: + %cmp2 = icmp slt i32 %x, %y + ret i1 %cmp2 +} + +define i1 @falseblock_cmp_is_false_commute(i32 %x, i32 %y) { +; CHECK-LABEL: @falseblock_cmp_is_false_commute( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]] +; CHECK: t: +; CHECK-NEXT: ret i1 [[CMP]] +; CHECK: f: +; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32 [[Y]], [[X]] +; CHECK-NEXT: ret i1 [[CMP2]] +; +entry: + %cmp = icmp eq i32 %x, %y + br i1 %cmp, label %t, label %f +t: + ret i1 %cmp +f: + %cmp2 = icmp eq i32 %y, %x + ret i1 %cmp2 +} + +define i1 @falseblock_cmp_is_true(i32 %x, i32 %y) { +; CHECK-LABEL: @falseblock_cmp_is_true( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]] +; CHECK: t: +; CHECK-NEXT: ret i1 [[CMP]] +; CHECK: f: +; CHECK-NEXT: [[CMP2:%.*]] = icmp uge i32 [[X]], [[Y]] +; CHECK-NEXT: ret i1 [[CMP2]] +; +entry: + %cmp = icmp ult i32 %x, %y + br i1 %cmp, label %t, label %f +t: + ret i1 %cmp +f: + %cmp2 = icmp uge i32 %x, %y + ret i1 %cmp2 +} + +define i1 @falseblock_cmp_is_true_commute(i32 %x, i32 %y) { +; CHECK-LABEL: @falseblock_cmp_is_true_commute( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]] +; CHECK: t: +; CHECK-NEXT: ret i1 [[CMP]] +; CHECK: f: +; CHECK-NEXT: [[CMP2:%.*]] = icmp sge i32 [[Y]], [[X]] +; CHECK-NEXT: ret i1 [[CMP2]] +; +entry: + %cmp = icmp sgt i32 %x, %y + br i1 %cmp, label %t, label %f +t: + ret i1 %cmp +f: + %cmp2 = icmp sge i32 %y, %x + ret i1 %cmp2 +} +