[llvm] [InstCombine] Allow overflowing selects to work on communative arguments (PR #90812)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 2 09:17:16 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
+ %s = select i1 %o, i32 -1, i32 %a
+ ret i32 %s
+}
----------------
goldsteinn wrote:
although missing a test for `sadd` still.
https://github.com/llvm/llvm-project/pull/90812
More information about the llvm-commits
mailing list