[llvm] [ConstraintElim] Simplify `MinMaxIntrinsic` (PR #75306)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 13 01:55:28 PST 2023
================
@@ -341,6 +341,147 @@ end:
ret i32 0
}
+; Test from PR75155
+define i32 @simplify_smax_val(i32 %a, i32 %b) {
+; CHECK-LABEL: define i32 @simplify_smax_val
+; CHECK-SAME: (i32 [[A:%.*]], i32 [[B:%.*]]) {
+; CHECK-NEXT: start:
+; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[A]], [[B]]
+; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
+; CHECK: then:
+; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[A]], 1
+; CHECK-NEXT: ret i32 [[B]]
+; CHECK: else:
+; CHECK-NEXT: ret i32 -1
+;
+start:
+ %cmp = icmp slt i32 %a, %b
+ br i1 %cmp, label %then, label %else
+then:
+ %add = add nsw i32 %a, 1
+ %max = call i32 @llvm.smax.i32(i32 %b, i32 %add)
----------------
fhahn wrote:
Could you also add tests where the operands are swapped?
https://github.com/llvm/llvm-project/pull/75306
More information about the llvm-commits
mailing list