diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp --- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp +++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp @@ -582,11 +582,15 @@ if (doesHold(CmpInst::ICMP_SGE, A, ConstantInt::get(B->getType(), 0))) addFact(CmpInst::ICMP_ULT, A, B, NumIn, NumOut, DFSInStack); break; - case CmpInst::ICMP_SGT: + case CmpInst::ICMP_SGT: { if (doesHold(CmpInst::ICMP_SGE, B, ConstantInt::get(B->getType(), -1))) addFact(CmpInst::ICMP_UGE, A, ConstantInt::get(B->getType(), 0), NumIn, NumOut, DFSInStack); + if (doesHold(CmpInst::ICMP_SGE, B, ConstantInt::get(B->getType(), 0))) + addFact(CmpInst::ICMP_UGT, A, B, NumIn, NumOut, DFSInStack); + break; + } case CmpInst::ICMP_SGE: if (doesHold(CmpInst::ICMP_SGE, B, ConstantInt::get(B->getType(), 0))) { addFact(CmpInst::ICMP_UGE, A, B, NumIn, NumOut, DFSInStack); diff --git a/llvm/test/Transforms/ConstraintElimination/gep-sub.ll b/llvm/test/Transforms/ConstraintElimination/gep-sub.ll --- a/llvm/test/Transforms/ConstraintElimination/gep-sub.ll +++ b/llvm/test/Transforms/ConstraintElimination/gep-sub.ll @@ -195,7 +195,7 @@ ; CHECK-NEXT: [[CMP_SUB_1:%.*]] = icmp ult ptr [[DST_SUB_1]], [[UPPER]] ; CHECK-NEXT: [[DST_SUB_2:%.*]] = getelementptr inbounds i8, ptr [[DST_ADD_IDX]], i64 -2 ; CHECK-NEXT: [[CMP_SUB_2:%.*]] = icmp ult ptr [[DST_SUB_2]], [[UPPER]] -; CHECK-NEXT: [[RES_1:%.*]] = xor i1 [[CMP_SUB_1]], [[CMP_SUB_2]] +; CHECK-NEXT: [[RES_1:%.*]] = xor i1 true, true ; CHECK-NEXT: [[DST_SUB_3:%.*]] = getelementptr inbounds i8, ptr [[DST_ADD_IDX]], i64 -3 ; CHECK-NEXT: [[CMP_SUB_3:%.*]] = icmp ult ptr [[DST_SUB_3]], [[UPPER]] ; CHECK-NEXT: [[RES_2:%.*]] = xor i1 [[RES_1]], [[CMP_SUB_3]] diff --git a/llvm/test/Transforms/ConstraintElimination/signed-query-unsigned-system.ll b/llvm/test/Transforms/ConstraintElimination/signed-query-unsigned-system.ll --- a/llvm/test/Transforms/ConstraintElimination/signed-query-unsigned-system.ll +++ b/llvm/test/Transforms/ConstraintElimination/signed-query-unsigned-system.ll @@ -39,7 +39,7 @@ ; CHECK-NEXT: call void @llvm.assume(i1 [[A_SGT_0]]) ; CHECK-NEXT: [[EXT:%.*]] = zext i8 [[A]] to i16 ; CHECK-NEXT: [[T:%.*]] = icmp sgt i16 [[EXT]], 0 -; CHECK-NEXT: ret i1 [[T]] +; CHECK-NEXT: ret i1 true ; %a.sgt.0 = icmp sgt i8 %a, 0 call void @llvm.assume(i1 %a.sgt.0) diff --git a/llvm/test/Transforms/ConstraintElimination/transfer-signed-facts-to-unsigned.ll b/llvm/test/Transforms/ConstraintElimination/transfer-signed-facts-to-unsigned.ll --- a/llvm/test/Transforms/ConstraintElimination/transfer-signed-facts-to-unsigned.ll +++ b/llvm/test/Transforms/ConstraintElimination/transfer-signed-facts-to-unsigned.ll @@ -580,7 +580,7 @@ ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]]) ; CHECK-NEXT: [[T_1:%.*]] = icmp ugt i8 [[IDX]], 2 ; CHECK-NEXT: [[T_2:%.*]] = icmp ugt i8 [[IDX]], 1 -; CHECK-NEXT: [[RES_1:%.*]] = xor i1 [[T_1]], [[T_2]] +; CHECK-NEXT: [[RES_1:%.*]] = xor i1 true, true ; CHECK-NEXT: [[C_1:%.*]] = icmp ugt i8 [[IDX]], 3 ; CHECK-NEXT: [[RES_2:%.*]] = xor i1 [[RES_1]], [[C_1]] ; CHECK-NEXT: ret i1 [[RES_2]] @@ -602,7 +602,7 @@ ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[A:%.*]], 2 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]]) ; CHECK-NEXT: [[T_1:%.*]] = icmp ugt i8 [[A]], 2 -; CHECK-NEXT: ret i1 [[T_1]] +; CHECK-NEXT: ret i1 true ; entry: %cmp = icmp sgt i8 %a, 2 @@ -617,7 +617,7 @@ ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[A:%.*]], 2 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]]) ; CHECK-NEXT: [[T_1:%.*]] = icmp ugt i8 [[A]], 1 -; CHECK-NEXT: ret i1 [[T_1]] +; CHECK-NEXT: ret i1 true ; entry: %cmp = icmp sgt i8 %a, 2 @@ -634,7 +634,7 @@ ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]]) ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP_2]]) ; CHECK-NEXT: [[T_1:%.*]] = icmp ugt i8 [[A]], [[B]] -; CHECK-NEXT: ret i1 [[T_1]] +; CHECK-NEXT: ret i1 true ; entry: %cmp = icmp sgt i8 %a, %b