[Mlir-commits] [mlir] [mlir][arith] Do not preserve nneg when folding extui of extui (PR #216315)

Jakub Kuderski llvmlistbot at llvm.org
Fri Aug 14 07:57:00 PDT 2026


================
@@ -451,6 +451,24 @@ func.func @extUIOfExtUI(%arg0: i1) -> i64 {
   return %ext2 : i64
 }
 
+// CHECK-LABEL: @extUIOfExtUI_outer_nneg
+//       CHECK:   %[[res:.+]] = arith.extui %arg0 : i1 to i64
+//       CHECK:   return %[[res]]
+func.func @extUIOfExtUI_outer_nneg(%arg0: i1) -> i64 {
+  %ext1 = arith.extui %arg0 : i1 to i8
+  %ext2 = arith.extui %ext1 nneg : i8 to i64
+  return %ext2 : i64
+}
+
+// CHECK-LABEL: @extUIOfExtUI_nneg
+//       CHECK:   %[[res:.+]] = arith.extui %arg0 nneg : i8 to i64
+//       CHECK:   return %[[res]]
+func.func @extUIOfExtUI_nneg(%arg0: i8) -> i64 {
----------------
kuhar wrote:

Please add the inner-only case: put `nneg` on the first `extui`, leave the outer one unflagged, and check that the folded operation gains `nneg`. This is the only branch where `setNonNeg(lhs.getNonNeg())` adds the flag, so the current outer-only and both-flag cases do not exercise it. Renaming the existing flagged test to `both_nneg` would also make the matrix clearer.


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


More information about the Mlir-commits mailing list