As far as I can tell FeatureLSLFast was originally added to specify that a lsl of <= 3 was cheap when folded into an addressing operand, so should override the one-use checks usually intended to make sure we don't perform redundant work. At a later point it also came to also mean that add x0, x1, x2, lsl N with N <= 4 was cheap, in that it took a single cycle not multiple cycles that more complex adds usually take. This patch splits those two concepts out into separate subtarget features. The biggest change is the change to AArch64DAGToDAGISel::isWorthFoldingALU, making ALU operations now produce a ADDWrs if the shift is <= 4. Otherwise the patch is mostly an NFC as it tries to keep the subtarget features the same for each cpu. I believe that the Arm OoO CPUs should eventually be changed to a new subtarget feature that specifies that a shift of 2 or 3 with any extend should be treated as cheap (just not shifts of 1 or 4). Differential Revision: https://reviews.llvm.org/D157982
130 lines
3.7 KiB
LLVM
130 lines
3.7 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
; RUN: llc < %s -mtriple=aarch64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-SLOW
|
|
; RUN: llc < %s -mtriple=aarch64-linux-gnu -mattr=+alu-lsl-fast | FileCheck %s --check-prefixes=CHECK,CHECK-FAST
|
|
|
|
define i32 @testmul3(i32 noundef %x, i32 noundef %y, i32 noundef %z) {
|
|
; CHECK-SLOW-LABEL: testmul3:
|
|
; CHECK-SLOW: // %bb.0: // %entry
|
|
; CHECK-SLOW-NEXT: lsl w8, w0, #3
|
|
; CHECK-SLOW-NEXT: add w9, w8, w1
|
|
; CHECK-SLOW-NEXT: add w8, w8, w2
|
|
; CHECK-SLOW-NEXT: mul w0, w8, w9
|
|
; CHECK-SLOW-NEXT: ret
|
|
;
|
|
; CHECK-FAST-LABEL: testmul3:
|
|
; CHECK-FAST: // %bb.0: // %entry
|
|
; CHECK-FAST-NEXT: add w8, w1, w0, lsl #3
|
|
; CHECK-FAST-NEXT: add w9, w2, w0, lsl #3
|
|
; CHECK-FAST-NEXT: mul w0, w9, w8
|
|
; CHECK-FAST-NEXT: ret
|
|
entry:
|
|
%shl = shl i32 %x, 3
|
|
%add = add nsw i32 %shl, %y
|
|
%add2 = add nsw i32 %shl, %z
|
|
%mul = mul nsw i32 %add2, %add
|
|
ret i32 %mul
|
|
}
|
|
|
|
define i32 @testvar(i32 noundef %x, i32 noundef %y, i32 noundef %z, i32 %zz) {
|
|
; CHECK-LABEL: testvar:
|
|
; CHECK: // %bb.0: // %entry
|
|
; CHECK-NEXT: lsl w8, w0, w3
|
|
; CHECK-NEXT: add w9, w8, w1
|
|
; CHECK-NEXT: add w8, w8, w2
|
|
; CHECK-NEXT: mul w0, w8, w9
|
|
; CHECK-NEXT: ret
|
|
entry:
|
|
%shl = shl i32 %x, %zz
|
|
%add = add nsw i32 %shl, %y
|
|
%add2 = add nsw i32 %shl, %z
|
|
%mul = mul nsw i32 %add2, %add
|
|
ret i32 %mul
|
|
}
|
|
|
|
define i32 @testmul5(i32 noundef %x, i32 noundef %y, i32 noundef %z) {
|
|
; CHECK-LABEL: testmul5:
|
|
; CHECK: // %bb.0: // %entry
|
|
; CHECK-NEXT: lsl w8, w0, #5
|
|
; CHECK-NEXT: add w9, w8, w1
|
|
; CHECK-NEXT: add w8, w8, w2
|
|
; CHECK-NEXT: mul w0, w8, w9
|
|
; CHECK-NEXT: ret
|
|
entry:
|
|
%shl = shl i32 %x, 5
|
|
%add = add nsw i32 %shl, %y
|
|
%add2 = add nsw i32 %shl, %z
|
|
%mul = mul nsw i32 %add2, %add
|
|
ret i32 %mul
|
|
}
|
|
|
|
define i64 @testsext3(i32 noundef %x, i64 noundef %y, i64 noundef %z) {
|
|
; CHECK-LABEL: testsext3:
|
|
; CHECK: // %bb.0: // %entry
|
|
; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
|
|
; CHECK-NEXT: sbfiz x8, x0, #3, #32
|
|
; CHECK-NEXT: add x9, x8, x1
|
|
; CHECK-NEXT: add x8, x8, x2
|
|
; CHECK-NEXT: mul x0, x9, x8
|
|
; CHECK-NEXT: ret
|
|
entry:
|
|
%conv = sext i32 %x to i64
|
|
%shl = shl nsw i64 %conv, 3
|
|
%add = add nsw i64 %shl, %y
|
|
%add3 = add nsw i64 %shl, %z
|
|
%mul = mul nsw i64 %add, %add3
|
|
ret i64 %mul
|
|
}
|
|
|
|
define i64 @testzext3(i32 noundef %x, i64 noundef %y, i64 noundef %z) {
|
|
; CHECK-LABEL: testzext3:
|
|
; CHECK: // %bb.0: // %entry
|
|
; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
|
|
; CHECK-NEXT: ubfiz x8, x0, #3, #32
|
|
; CHECK-NEXT: add x9, x8, x1
|
|
; CHECK-NEXT: add x8, x8, x2
|
|
; CHECK-NEXT: mul x0, x9, x8
|
|
; CHECK-NEXT: ret
|
|
entry:
|
|
%conv = zext i32 %x to i64
|
|
%shl = shl nsw i64 %conv, 3
|
|
%add = add nsw i64 %shl, %y
|
|
%add3 = add nsw i64 %shl, %z
|
|
%mul = mul nsw i64 %add, %add3
|
|
ret i64 %mul
|
|
}
|
|
|
|
define i64 @test3sext(i32 noundef %x, i64 noundef %y, i64 noundef %z) {
|
|
; CHECK-LABEL: test3sext:
|
|
; CHECK: // %bb.0: // %entry
|
|
; CHECK-NEXT: lsl w8, w0, #3
|
|
; CHECK-NEXT: sxtw x8, w8
|
|
; CHECK-NEXT: add x9, x8, x1
|
|
; CHECK-NEXT: add x8, x8, x2
|
|
; CHECK-NEXT: mul x0, x9, x8
|
|
; CHECK-NEXT: ret
|
|
entry:
|
|
%shl = shl i32 %x, 3
|
|
%conv = sext i32 %shl to i64
|
|
%add = add nsw i64 %conv, %y
|
|
%add3 = add nsw i64 %conv, %z
|
|
%mul = mul nsw i64 %add, %add3
|
|
ret i64 %mul
|
|
}
|
|
|
|
define i64 @test3zext(i32 noundef %x, i64 noundef %y, i64 noundef %z) {
|
|
; CHECK-LABEL: test3zext:
|
|
; CHECK: // %bb.0: // %entry
|
|
; CHECK-NEXT: lsl w8, w0, #3
|
|
; CHECK-NEXT: add x9, x8, x1
|
|
; CHECK-NEXT: add x8, x8, x2
|
|
; CHECK-NEXT: mul x0, x9, x8
|
|
; CHECK-NEXT: ret
|
|
entry:
|
|
%shl = shl i32 %x, 3
|
|
%conv = zext i32 %shl to i64
|
|
%add = add nsw i64 %conv, %y
|
|
%add3 = add nsw i64 %conv, %z
|
|
%mul = mul nsw i64 %add, %add3
|
|
ret i64 %mul
|
|
}
|