[llvm] [ConstraintElim] Add pre-commit tests for PR76299. NFC. (PR #76512)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 28 08:34:46 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Yingwei Zheng (dtcxzyw)
<details>
<summary>Changes</summary>
This patch adds pre-commit tests for #<!-- -->76299.
#<!-- -->76262 caused a regression in [velox/buffer/Buffer.h](https://github.com/facebookincubator/velox/blob/50187434e32bffcbebcd6501898763c56de40065/velox/buffer/Buffer.h#L347-L350).
See also https://github.com/dtcxzyw/llvm-opt-benchmark/issues/35#issuecomment-1868362725.
---
Full diff: https://github.com/llvm/llvm-project/pull/76512.diff
1 Files Affected:
- (added) llvm/test/Transforms/ConstraintElimination/constraint-overflow.ll (+40)
``````````diff
diff --git a/llvm/test/Transforms/ConstraintElimination/constraint-overflow.ll b/llvm/test/Transforms/ConstraintElimination/constraint-overflow.ll
new file mode 100644
index 00000000000000..88f87f4afab286
--- /dev/null
+++ b/llvm/test/Transforms/ConstraintElimination/constraint-overflow.ll
@@ -0,0 +1,40 @@
+; 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 i32 @f(i64 %a3, i64 %numElements) {
+; CHECK-LABEL: define i32 @f(
+; CHECK-SAME: i64 [[A3:%.*]], i64 [[NUMELEMENTS:%.*]]) {
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[COND:%.*]] = icmp ule i64 [[NUMELEMENTS]], 1152921504606846975
+; CHECK-NEXT: call void @llvm.assume(i1 [[COND]])
+; CHECK-NEXT: [[A1:%.*]] = shl nuw i64 [[NUMELEMENTS]], 4
+; CHECK-NEXT: br label [[IF_END:%.*]]
+; CHECK: if.end:
+; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i64 [[A1]], [[A3]]
+; CHECK-NEXT: br i1 [[CMP]], label [[IF_END_I:%.*]], label [[ABORT:%.*]]
+; CHECK: if.end.i:
+; CHECK-NEXT: [[CMP2_NOT_I:%.*]] = icmp ult i64 [[A1]], [[A3]]
+; CHECK-NEXT: br i1 [[CMP2_NOT_I]], label [[ABORT]], label [[EXIT:%.*]]
+; CHECK: abort:
+; CHECK-NEXT: ret i32 -1
+; CHECK: exit:
+; CHECK-NEXT: ret i32 0
+;
+entry:
+ %cond = icmp ule i64 %numElements, 1152921504606846975
+ call void @llvm.assume(i1 %cond)
+ %a1 = shl nuw i64 %numElements, 4
+ br label %if.end
+if.end:
+ %cmp = icmp ugt i64 %a1, %a3
+ br i1 %cmp, label %if.end.i, label %abort
+if.end.i:
+ %cmp2.not.i = icmp ult i64 %a1, %a3
+ br i1 %cmp2.not.i, label %abort, label %exit
+abort:
+ ret i32 -1
+exit:
+ ret i32 0
+}
+
+declare void @llvm.assume(i1)
``````````
</details>
https://github.com/llvm/llvm-project/pull/76512
More information about the llvm-commits
mailing list