[llvm] [ConstraintElim] Add facts implied by llvm.abs (PR #73189)
Alexander Shaposhnikov via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 4 15:32:35 PST 2023
================
@@ -0,0 +1,39 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
+; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
+
+define i1 @abs_int_min_is_not_poison(i32 %arg) {
+; CHECK-LABEL: define i1 @abs_int_min_is_not_poison(
+; CHECK-SAME: i32 [[ARG:%.*]]) {
+; CHECK-NEXT: [[ABS:%.*]] = tail call i32 @llvm.abs.i32(i32 [[ARG]], i1 false)
+; CHECK-NEXT: ret i1 true
+;
+ %abs = tail call i32 @llvm.abs.i32(i32 %arg, i1 false)
+ %cmp = icmp sge i32 %abs, %arg
+ ret i1 %cmp
+}
+
+define i1 @abs_int_min_is_poison(i32 %arg) {
+; CHECK-LABEL: define i1 @abs_int_min_is_poison(
+; CHECK-SAME: i32 [[ARG:%.*]]) {
+; CHECK-NEXT: [[ABS:%.*]] = tail call i32 @llvm.abs.i32(i32 [[ARG]], i1 true)
+; CHECK-NEXT: ret i1 true
+;
+ %abs = tail call i32 @llvm.abs.i32(i32 %arg, i1 true)
+ %cmp = icmp sge i32 %abs, %arg
+ ret i1 %cmp
+}
+
+define i1 @abs_plus_one(i32 %arg) {
+; CHECK-LABEL: define i1 @abs_plus_one(
+; CHECK-SAME: i32 [[ARG:%.*]]) {
+; CHECK-NEXT: [[ABS:%.*]] = tail call i32 @llvm.abs.i32(i32 [[ARG]], i1 true)
+; CHECK-NEXT: [[ABS_PLUS_ONE:%.*]] = add nsw i32 [[ABS]], 1
+; CHECK-NEXT: ret i1 true
+;
+ %abs = tail call i32 @llvm.abs.i32(i32 %arg, i1 true)
----------------
alexander-shaposhnikov wrote:
yup
https://github.com/llvm/llvm-project/pull/73189
More information about the llvm-commits
mailing list