[llvm] [InstCombine] Fold zext(icmp ne X, C) to X - C when X is in (C, C+1) (PR #208914)

Andreas Jonson via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 13 02:33:06 PDT 2026


================
@@ -1080,3 +1080,96 @@ define <2 x i8> @zext_or_trunc_nuw_vec(<2 x i8> %x, <2 x i4> %y) {
   %zext = zext <2 x i4> %or to <2 x i8>
   ret <2 x i8> %zext
 }
+
+; zext (X != CST) --> X - CST        if X in {CST, CST + 1}
+
+define i32 @zext_ne_lower_cst_sub(i32 range(i32 7, 9) %x) {
----------------
andjo403 wrote:

think that it can be good with a extra test for range 0 , 2 

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


More information about the llvm-commits mailing list