[llvm] [ConstraintElim] Decompose sext-like insts for signed predicates (PR #82344)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 20 03:52:38 PST 2024
================
@@ -601,6 +601,123 @@ else:
ret i32 -1
}
+define i64 @pr82271(i32 %a, i32 %b){
+; CHECK-LABEL: define i64 @pr82271
+; CHECK-SAME: (i32 [[A:%.*]], i32 [[B:%.*]]) {
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[A]], [[B]]
+; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
+; CHECK: then:
+; CHECK-NEXT: [[SA:%.*]] = sext i32 [[A]] to i64
+; CHECK-NEXT: [[SB:%.*]] = sext i32 [[B]] to i64
+; CHECK-NEXT: [[ADD:%.*]] = add nsw i64 [[SA]], 1
+; CHECK-NEXT: ret i64 [[SB]]
+; CHECK: else:
+; CHECK-NEXT: ret i64 0
+;
+entry:
+ %cmp = icmp slt i32 %a, %b
+ br i1 %cmp, label %then, label %else
+
+then:
+ %sa = sext i32 %a to i64
+ %sb = sext i32 %b to i64
+ %add = add nsw i64 %sa, 1
----------------
fhahn wrote:
Could you also add tests that check SExt/NNEgZExt support without min/max, e.g. by having a compare of the extended values?
https://github.com/llvm/llvm-project/pull/82344
More information about the llvm-commits
mailing list