[Mlir-commits] [mlir] [MLIR] Unconditionally take min of max lhs/rhs value in inferRemU (PR #110169)

Krzysztof Drewniak llvmlistbot at llvm.org
Tue Oct 1 08:09:41 PDT 2024


================
@@ -266,6 +266,18 @@ func.func @remui_base(%arg0 : index, %arg1 : index ) -> i1 {
     func.return %3 : i1
 }
 
+// CHECK-LABEL: func @remui_base_maybe_zero
+// CHECK: %[[true:.*]] = arith.constant true
+// CHECK: return %[[true]]
+func.func @remui_base_maybe_zero(%arg0 : index, %arg1 : index ) -> i1 {
+    %c4 = arith.constant 4 : index
+
+    %0 = arith.minui %arg1, %c4 : index
+    %1 = arith.remui %arg0, %0 : index
+    %2 = arith.cmpi ult, %1, %c4 : index
+    func.return %2 : i1
+}    
----------------
krzysz00 wrote:

Having checked, [alive2 is happy with this, even in its general form](https://alive2.llvm.org/ce/#g:!((g:!((g:!((h:codeEditor,i:(fontScale:14,j:1,lang:llvm,selection:(endColumn:16,endLineNumber:21,positionColumn:16,positionLineNumber:21,selectionStartColumn:16,selectionStartLineNumber:21,startColumn:16,startLineNumber:21),source:'declare+i8+ at llvm.umin.i8(i8,+i8)%0A%0Adefine+i1+ at src_drop_urem(i8+%25x,+i8+%25y)+%7B%0A++%25clamp+%3D+call+i8+ at llvm.umin.i8(i8+%25x,+i8+4)%0A++%25mod+%3D+urem+i8+%25y,+%25clamp%0A++%25ret+%3D+icmp+ult+i8+%25mod,+4%0A++ret+i1+%25ret%0A%7D%0A%0Adefine+i1+ at tgt_drop_urem(i8+%25x,+i8+%25y)+%7B%0A++ret+i1+1%0A%7D%0A%0Adefine+i1+ at src_drop_urem_noconst(i8+%25x,+i8+%25y,+i8+%25z)+%7B%0A++%25clamp+%3D+call+i8+ at llvm.umin.i8(i8+%25x,+i8+%25z)%0A++%25mod+%3D+urem+i8+%25y,+%25clamp%0A++%25ret+%3D+icmp+ult+i8+%25mod,+%25z%0A++ret+i1+%25ret%0A%7D%0A%0Adefine+i1+ at tgt_drop_urem_noconst(i8+%25x,+i8+%25y,+i8+%25z)+%7B%0A++ret+i1+1%0A%7D'),l:'5',n:'0',o:'LLVM+IR+source+%231',t:'0')),k:30.812101910828027,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:alive,filters:(b:'0',binary:'1',commentOnly:'0',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'1',trim:'1'),fontScale:14,j:1,lang:llvm,libs:!(),options:'',selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'alive-tv+(Editor+%231,+Compiler+%231)+LLVM+IR',t:'0')),k:69.18789808917197,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4)



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


More information about the Mlir-commits mailing list