[llvm] [InstCombine] Allow overflowing selects to work on commutative arguments (PR #90812)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sun May 5 19:51:39 PDT 2024


================
@@ -13,6 +13,18 @@ define i32 @uadd(i32 %x, i32 %y) {
   ret i32 %s
 }
 
+define i32 @uadd_cumm(i32 %x, i32 %y) {
+; CHECK-LABEL: @uadd_cumm(
+; CHECK-NEXT:    [[S:%.*]] = call i32 @llvm.uadd.sat.i32(i32 [[X:%.*]], i32 [[Y:%.*]])
+; CHECK-NEXT:    ret i32 [[S]]
+;
+  %ao = tail call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %x, i32 %y)
+  %o = extractvalue { i32, i1 } %ao, 1
+  %a = add i32 %y, %x
----------------
topperc wrote:

Does the case with `add i32 %x, %y` here already work before this patch or do we need a test for it too?

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


More information about the llvm-commits mailing list