2018-08-30 17:32:21 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
|
|
; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s
|
|
|
|
|
|
|
|
define i32 @test_minsize(i32 %X) optsize minsize nounwind readnone {
|
|
|
|
; CHECK-LABEL: test_minsize:
|
|
|
|
; CHECK: // %bb.0:
|
|
|
|
; CHECK-NEXT: mov w8, #5
|
|
|
|
; CHECK-NEXT: udiv w8, w0, w8
|
|
|
|
; CHECK-NEXT: add w8, w8, w8, lsl #2
|
|
|
|
; CHECK-NEXT: mov w9, #-10
|
|
|
|
; CHECK-NEXT: cmp w0, w8
|
|
|
|
; CHECK-NEXT: mov w8, #42
|
|
|
|
; CHECK-NEXT: csel w0, w8, w9, eq
|
|
|
|
; CHECK-NEXT: ret
|
|
|
|
%rem = urem i32 %X, 5
|
|
|
|
%cmp = icmp eq i32 %rem, 0
|
|
|
|
%ret = select i1 %cmp, i32 42, i32 -10
|
|
|
|
ret i32 %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test_optsize(i32 %X) optsize nounwind readnone {
|
|
|
|
; CHECK-LABEL: test_optsize:
|
|
|
|
; CHECK: // %bb.0:
|
|
|
|
; CHECK-NEXT: mov w8, #52429
|
|
|
|
; CHECK-NEXT: movk w8, #52428, lsl #16
|
[CodeGen] [SelectionDAG] More efficient code for X % C == 0 (UREM case) (try 3)
Summary:
I'm submitting a new revision since i don't understand how to reclaim/reopen/take over the existing one, D50222.
There is no such action in "Add Action" menu...
This implements an optimization described in Hacker's Delight 10-17: when `C` is constant,
the result of `X % C == 0` can be computed more cheaply without actually calculating the remainder.
The motivation is discussed here: https://bugs.llvm.org/show_bug.cgi?id=35479.
This is a recommit, the original commit rL364563 was reverted in rL364568
because test-suite detected miscompile - the new comparison constant 'Q'
was being computed incorrectly (we divided by `D0` instead of `D`).
Original patch D50222 by @hermord (Dmytro Shynkevych)
Notes:
- In principle, it's possible to also handle the `X % C1 == C2` case, as discussed on bugzilla.
This seems to require an extra branch on overflow, so I refrained from implementing this for now.
- An explicit check for when the `REM` can be reduced to just its LHS is included:
the `X % C` == 0 optimization breaks `test1` in `test/CodeGen/X86/jump_sign.ll` otherwise.
I hadn't managed to find a better way to not generate worse output in this case.
- The `test/CodeGen/X86/jump_sign.ll` regresses, and is being fixed by a followup patch D63390.
Reviewers: RKSimon, craig.topper, spatel, hermord, xbolva00
Reviewed By: RKSimon, xbolva00
Subscribers: dexonsmith, kristina, xbolva00, javed.absar, llvm-commits, hermord
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63391
llvm-svn: 364600
2019-06-28 05:52:10 +08:00
|
|
|
; CHECK-NEXT: mov w9, #13108
|
|
|
|
; CHECK-NEXT: movk w9, #13107, lsl #16
|
|
|
|
; CHECK-NEXT: mul w8, w0, w8
|
|
|
|
; CHECK-NEXT: mov w10, #-10
|
|
|
|
; CHECK-NEXT: cmp w8, w9
|
2018-08-30 17:32:21 +08:00
|
|
|
; CHECK-NEXT: mov w8, #42
|
[CodeGen] [SelectionDAG] More efficient code for X % C == 0 (UREM case) (try 3)
Summary:
I'm submitting a new revision since i don't understand how to reclaim/reopen/take over the existing one, D50222.
There is no such action in "Add Action" menu...
This implements an optimization described in Hacker's Delight 10-17: when `C` is constant,
the result of `X % C == 0` can be computed more cheaply without actually calculating the remainder.
The motivation is discussed here: https://bugs.llvm.org/show_bug.cgi?id=35479.
This is a recommit, the original commit rL364563 was reverted in rL364568
because test-suite detected miscompile - the new comparison constant 'Q'
was being computed incorrectly (we divided by `D0` instead of `D`).
Original patch D50222 by @hermord (Dmytro Shynkevych)
Notes:
- In principle, it's possible to also handle the `X % C1 == C2` case, as discussed on bugzilla.
This seems to require an extra branch on overflow, so I refrained from implementing this for now.
- An explicit check for when the `REM` can be reduced to just its LHS is included:
the `X % C` == 0 optimization breaks `test1` in `test/CodeGen/X86/jump_sign.ll` otherwise.
I hadn't managed to find a better way to not generate worse output in this case.
- The `test/CodeGen/X86/jump_sign.ll` regresses, and is being fixed by a followup patch D63390.
Reviewers: RKSimon, craig.topper, spatel, hermord, xbolva00
Reviewed By: RKSimon, xbolva00
Subscribers: dexonsmith, kristina, xbolva00, javed.absar, llvm-commits, hermord
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63391
llvm-svn: 364600
2019-06-28 05:52:10 +08:00
|
|
|
; CHECK-NEXT: csel w0, w8, w10, lo
|
2018-08-30 17:32:21 +08:00
|
|
|
; CHECK-NEXT: ret
|
|
|
|
%rem = urem i32 %X, 5
|
|
|
|
%cmp = icmp eq i32 %rem, 0
|
|
|
|
%ret = select i1 %cmp, i32 42, i32 -10
|
|
|
|
ret i32 %ret
|
|
|
|
}
|