[llvm] [ConstraintElim] Simplify `MinMaxIntrinsic` (PR #75306)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 13 01:55:29 PST 2023


================
@@ -1009,6 +1009,13 @@ void State::addInfoFor(BasicBlock &BB) {
 
     if (isa<MinMaxIntrinsic>(&I)) {
       WorkList.push_back(FactOrCheck::getInstFact(DT.getNode(&BB), &I));
+      for (Use &U : I.uses()) {
+        auto *UserI = getContextInstForUse(U);
----------------
fhahn wrote:

Is queuing the users actually needed for any of the test case? It looks like in all cases the MinMax intrinsics are in a block dominated by the relevant condition.

Solving at the uses would only be needed for cases like below, unless I am missing something? If that's the case, please add support for optimizing uses of MinMaxIntrinsics separately.

```
 define i32 @simplify_umax_val(i32 %a, i32 %b) {
 start:
   %add = add nuw i32 %a, 1
   %max = call i32 @llvm.umax.i32(i32 %b, i32 %add)
   %cmp = icmp ult i32 %a, %b
   br i1 %cmp, label %then, label %else
 then:
   ret i32 %max
 else:
   ret i32 -1
 }
```



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


More information about the llvm-commits mailing list