[llvm] [InstCombine] Fold uadd.sat comparison using known operand relation (PR #212776)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 29 22:50:51 PDT 2026
================
@@ -119,6 +119,95 @@ define i1 @icmp_sgt_basic(i16 %arg) {
ret i1 %cmp
}
+; ==============================================================================
+; Tests with non-constant operands
+; ==============================================================================
+define i1 @icmp_ult_assume_c_ule_c2(i8 %x, i8 %c, i8 %c2) {
+; CHECK-LABEL: define i1 @icmp_ult_assume_c_ule_c2(
+; CHECK-SAME: i8 [[X:%.*]], i8 [[C:%.*]], i8 [[C2:%.*]]) {
+; CHECK-NEXT: [[COND:%.*]] = icmp ule i8 [[C]], [[C2]]
+; CHECK-NEXT: call void @llvm.assume(i1 [[COND]])
+; CHECK-NEXT: [[LIMIT:%.*]] = sub i8 [[C2]], [[C]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[X]], [[LIMIT]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %cond = icmp ule i8 %c, %c2
+ call void @llvm.assume(i1 %cond)
----------------
ParkHanbum wrote:
You do not need to include an `assume` in the tests.
In Alive2, we used `assume` to prove that the transformation is valid under a specific condition. In the actual patch, however, that condition is checked directly in the implementation.
For the tests, please use constant values that directly exercise the boundaries of the implemented condition check.
https://github.com/llvm/llvm-project/pull/212776
More information about the llvm-commits
mailing list