[llvm] [InstCombine] Add combines for unsigned comparison of absolute value to constant (PR #176148)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 19 10:20:52 PST 2026


================
@@ -997,3 +997,195 @@ define i8 @abs_diff_sle_y_x(i8 %x, i8 %y) {
   %cond = select i1 %cmp, i8 %sub, i8 %sub1
   ret i8 %cond
 }
+
+define i1 @abs_cmp_ule_no_poison(i32 %x) {
+; CHECK-LABEL: @abs_cmp_ule_no_poison(
+; CHECK-NEXT:    [[X_ABS:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 false)
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i32 [[X_ABS]], 32
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %x.abs = call i32 @llvm.abs.i32(i32 %x, i1 0)
----------------
dtcxzyw wrote:

Use i1 false/true

https://github.com/llvm/llvm-project/pull/176148


More information about the llvm-commits mailing list