[llvm] Simplify `(a % b) lt/ge (b-1)` into `(a % b) eq/ne (b-1)` (PR #72504)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 4 03:33:13 PST 2024
================
@@ -10,6 +10,315 @@ declare void @use_i8(i8)
declare void @use_i32(i32)
declare void @use_i64(i64)
+; tests for (x % c) >=/ < (c - 1), where c >= 0
+define i1 @srem_sge_test1(i64 %x) {
+; CHECK-LABEL: @srem_sge_test1(
+; CHECK-NEXT: [[Y:%.*]] = srem i64 [[X:%.*]], 34360750831
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[Y]], 34360750830
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %Cminus1 = add i64 34360750831, -1
+ %y = srem i64 %x, 34360750831
+ %cmp = icmp sge i64 %y, %Cminus1
----------------
dtcxzyw wrote:
> what is the reason for the check failure?
It is a flang issue. You can push something to rerun the CI.
> I have a question, but it doesn't relate to this patch, If I am developing a new backend instruction that does stack allocation it lowers alloca to the target architecture.
do you have a link for similar patches for any architecture?
For static allocation, `CodeGen` will do the most of things for you. Then you should provide a target-specific implementation of `TargetFrameLowering` to maintain the stack.
For dynamic allocation, SDAG will transform it into `ISD::DYNAMIC_STACKALLOC`. Then you should lower it into target-specific insts.
Please file an issue if you want to ask more about the backend.
https://github.com/llvm/llvm-project/pull/72504
More information about the llvm-commits
mailing list