1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=aarch64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-SLOW 3; RUN: llc < %s -mtriple=aarch64-linux-gnu -mattr=+alu-lsl-fast | FileCheck %s --check-prefixes=CHECK,CHECK-FAST 4 5define i32 @testmul3(i32 noundef %x, i32 noundef %y, i32 noundef %z) { 6; CHECK-SLOW-LABEL: testmul3: 7; CHECK-SLOW: // %bb.0: // %entry 8; CHECK-SLOW-NEXT: lsl w8, w0, #3 9; CHECK-SLOW-NEXT: add w9, w8, w1 10; CHECK-SLOW-NEXT: add w8, w8, w2 11; CHECK-SLOW-NEXT: mul w0, w8, w9 12; CHECK-SLOW-NEXT: ret 13; 14; CHECK-FAST-LABEL: testmul3: 15; CHECK-FAST: // %bb.0: // %entry 16; CHECK-FAST-NEXT: add w8, w1, w0, lsl #3 17; CHECK-FAST-NEXT: add w9, w2, w0, lsl #3 18; CHECK-FAST-NEXT: mul w0, w9, w8 19; CHECK-FAST-NEXT: ret 20entry: 21 %shl = shl i32 %x, 3 22 %add = add nsw i32 %shl, %y 23 %add2 = add nsw i32 %shl, %z 24 %mul = mul nsw i32 %add2, %add 25 ret i32 %mul 26} 27 28define i32 @testvar(i32 noundef %x, i32 noundef %y, i32 noundef %z, i32 %zz) { 29; CHECK-LABEL: testvar: 30; CHECK: // %bb.0: // %entry 31; CHECK-NEXT: lsl w8, w0, w3 32; CHECK-NEXT: add w9, w8, w1 33; CHECK-NEXT: add w8, w8, w2 34; CHECK-NEXT: mul w0, w8, w9 35; CHECK-NEXT: ret 36entry: 37 %shl = shl i32 %x, %zz 38 %add = add nsw i32 %shl, %y 39 %add2 = add nsw i32 %shl, %z 40 %mul = mul nsw i32 %add2, %add 41 ret i32 %mul 42} 43 44define i32 @testmul5(i32 noundef %x, i32 noundef %y, i32 noundef %z) { 45; CHECK-LABEL: testmul5: 46; CHECK: // %bb.0: // %entry 47; CHECK-NEXT: lsl w8, w0, #5 48; CHECK-NEXT: add w9, w8, w1 49; CHECK-NEXT: add w8, w8, w2 50; CHECK-NEXT: mul w0, w8, w9 51; CHECK-NEXT: ret 52entry: 53 %shl = shl i32 %x, 5 54 %add = add nsw i32 %shl, %y 55 %add2 = add nsw i32 %shl, %z 56 %mul = mul nsw i32 %add2, %add 57 ret i32 %mul 58} 59 60define i64 @testsext3(i32 noundef %x, i64 noundef %y, i64 noundef %z) { 61; CHECK-LABEL: testsext3: 62; CHECK: // %bb.0: // %entry 63; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0 64; CHECK-NEXT: sbfiz x8, x0, #3, #32 65; CHECK-NEXT: add x9, x8, x1 66; CHECK-NEXT: add x8, x8, x2 67; CHECK-NEXT: mul x0, x9, x8 68; CHECK-NEXT: ret 69entry: 70 %conv = sext i32 %x to i64 71 %shl = shl nsw i64 %conv, 3 72 %add = add nsw i64 %shl, %y 73 %add3 = add nsw i64 %shl, %z 74 %mul = mul nsw i64 %add, %add3 75 ret i64 %mul 76} 77 78define i64 @testzext3(i32 noundef %x, i64 noundef %y, i64 noundef %z) { 79; CHECK-LABEL: testzext3: 80; CHECK: // %bb.0: // %entry 81; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0 82; CHECK-NEXT: ubfiz x8, x0, #3, #32 83; CHECK-NEXT: add x9, x8, x1 84; CHECK-NEXT: add x8, x8, x2 85; CHECK-NEXT: mul x0, x9, x8 86; CHECK-NEXT: ret 87entry: 88 %conv = zext i32 %x to i64 89 %shl = shl nsw i64 %conv, 3 90 %add = add nsw i64 %shl, %y 91 %add3 = add nsw i64 %shl, %z 92 %mul = mul nsw i64 %add, %add3 93 ret i64 %mul 94} 95 96define i64 @test3sext(i32 noundef %x, i64 noundef %y, i64 noundef %z) { 97; CHECK-LABEL: test3sext: 98; CHECK: // %bb.0: // %entry 99; CHECK-NEXT: lsl w8, w0, #3 100; CHECK-NEXT: sxtw x8, w8 101; CHECK-NEXT: add x9, x8, x1 102; CHECK-NEXT: add x8, x8, x2 103; CHECK-NEXT: mul x0, x9, x8 104; CHECK-NEXT: ret 105entry: 106 %shl = shl i32 %x, 3 107 %conv = sext i32 %shl to i64 108 %add = add nsw i64 %conv, %y 109 %add3 = add nsw i64 %conv, %z 110 %mul = mul nsw i64 %add, %add3 111 ret i64 %mul 112} 113 114define i64 @test3zext(i32 noundef %x, i64 noundef %y, i64 noundef %z) { 115; CHECK-LABEL: test3zext: 116; CHECK: // %bb.0: // %entry 117; CHECK-NEXT: lsl w8, w0, #3 118; CHECK-NEXT: add x9, x8, x1 119; CHECK-NEXT: add x8, x8, x2 120; CHECK-NEXT: mul x0, x9, x8 121; CHECK-NEXT: ret 122entry: 123 %shl = shl i32 %x, 3 124 %conv = zext i32 %shl to i64 125 %add = add nsw i64 %conv, %y 126 %add3 = add nsw i64 %conv, %z 127 %mul = mul nsw i64 %add, %add3 128 ret i64 %mul 129} 130