1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64 < %s | FileCheck %s
4 ; Check that we optimize out AND instructions and ADD/SUB instructions
5 ; modulo the shift size to take advantage of the implicit mod done on
6 ; the shift amount value by the variable shift/rotate instructions.
8 define i32 @test1(i32 %x, i64 %y) {
11 ; CHECK-NEXT: lsr w0, w0, w1
13 %sh_prom = trunc i64 %y to i32
14 %shr = lshr i32 %x, %sh_prom
18 define i64 @test2(i32 %x, i64 %y) {
21 ; CHECK-NEXT: neg w[[REG:[0-9]+]], w0
22 ; CHECK-NEXT: asr x0, x1, x[[REG]]
24 %sub9 = sub nsw i32 64, %x
25 %sh_prom12.i = zext i32 %sub9 to i64
26 %shr.i = ashr i64 %y, %sh_prom12.i
30 define i64 @test3(i64 %x, i64 %y) {
33 ; CHECK-NEXT: lsl x0, x1, x0
35 %add = add nsw i64 64, %x
36 %shl = shl i64 %y, %add
40 define i64 @test4(i64 %y, i32 %s) {
42 ; CHECK: // %bb.0: // %entry
43 ; CHECK-NEXT: // kill: def $w1 killed $w1 def $x1
44 ; CHECK-NEXT: asr x0, x0, x1
47 %sh_prom = zext i32 %s to i64
48 %shr = ashr i64 %y, %sh_prom
52 define i64 @test5(i64 %y, i32 %s) {
54 ; CHECK: // %bb.0: // %entry
55 ; CHECK-NEXT: // kill: def $w1 killed $w1 def $x1
56 ; CHECK-NEXT: asr x0, x0, x1
59 %sh_prom = sext i32 %s to i64
60 %shr = ashr i64 %y, %sh_prom
64 define i64 @test6(i64 %y, i32 %s) {
66 ; CHECK: // %bb.0: // %entry
67 ; CHECK-NEXT: // kill: def $w1 killed $w1 def $x1
68 ; CHECK-NEXT: lsl x0, x0, x1
71 %sh_prom = sext i32 %s to i64
72 %shr = shl i64 %y, %sh_prom