[llvm] f072263 - [AArch64] Add some extra typepromotion cost tests. NFC

David Green via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 12 03:13:31 PDT 2022


Author: David Green
Date: 2022-09-12T11:13:23+01:00
New Revision: f072263e9f626fee0429d3ee444814b3648b2953

URL: https://github.com/llvm/llvm-project/commit/f072263e9f626fee0429d3ee444814b3648b2953
DIFF: https://github.com/llvm/llvm-project/commit/f072263e9f626fee0429d3ee444814b3648b2953.diff

LOG: [AArch64] Add some extra typepromotion cost tests. NFC

Added: 
    llvm/test/CodeGen/AArch64/typepromotion-cost.ll

Modified: 
    llvm/test/CodeGen/AArch64/rm_redundant_cmp.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/AArch64/rm_redundant_cmp.ll b/llvm/test/CodeGen/AArch64/rm_redundant_cmp.ll
index 22d0584f63b0..a02255e05927 100644
--- a/llvm/test/CodeGen/AArch64/rm_redundant_cmp.ll
+++ b/llvm/test/CodeGen/AArch64/rm_redundant_cmp.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc < %s -mtriple=aarch64-linux-gnuabi -O2 | FileCheck %s
 
 ; The following cases are for i16
@@ -9,11 +10,18 @@
 @cost_u_i16 = common global %struct.s_unsigned_i16 zeroinitializer, align 2
 
 define void @test_i16_2cmp_signed_1() {
-; CHECK-LABEL: test_i16_2cmp_signed_1
-; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
-; CHECK-NEXT: b.lt
-; CHECK-NOT: cmp
-; CHECK: ret
+; CHECK-LABEL: test_i16_2cmp_signed_1:
+; CHECK:       // %bb.0: // %entry
+; CHECK-NEXT:    adrp x8, :got:cost_s_i8_i16
+; CHECK-NEXT:    ldr x8, [x8, :got_lo12:cost_s_i8_i16]
+; CHECK-NEXT:    ldrsh w9, [x8, #2]
+; CHECK-NEXT:    ldrsh w10, [x8, #4]
+; CHECK-NEXT:    cmp w9, w10
+; CHECK-NEXT:    b.lt .LBB0_2
+; CHECK-NEXT:  // %bb.1: // %if.end8.sink.split
+; CHECK-NEXT:    strh w9, [x8]
+; CHECK-NEXT:  .LBB0_2: // %if.end8
+; CHECK-NEXT:    ret
 entry:
   %0 = load i16, i16* getelementptr inbounds (%struct.s_signed_i16, %struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 1), align 2
   %1 = load i16, i16* getelementptr inbounds (%struct.s_signed_i16, %struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 2), align 2
@@ -37,11 +45,21 @@ if.end8:                                          ; preds = %if.else, %if.then7,
 }
 
 define void @test_i16_2cmp_signed_2() {
-; CHECK-LABEL: test_i16_2cmp_signed_2
-; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
-; CHECK-NEXT: b.gt
-; CHECK-NOT: cmp
-; CHECK: b.ge
+; CHECK-LABEL: test_i16_2cmp_signed_2:
+; CHECK:       // %bb.0: // %entry
+; CHECK-NEXT:    adrp x8, :got:cost_s_i8_i16
+; CHECK-NEXT:    ldr x8, [x8, :got_lo12:cost_s_i8_i16]
+; CHECK-NEXT:    ldrsh w9, [x8, #2]
+; CHECK-NEXT:    ldrsh w10, [x8, #4]
+; CHECK-NEXT:    cmp w9, w10
+; CHECK-NEXT:    b.gt .LBB1_2
+; CHECK-NEXT:  // %bb.1: // %if.else
+; CHECK-NEXT:    mov w9, w10
+; CHECK-NEXT:    b.ge .LBB1_3
+; CHECK-NEXT:  .LBB1_2: // %if.end8.sink.split
+; CHECK-NEXT:    strh w9, [x8]
+; CHECK-NEXT:  .LBB1_3: // %if.end8
+; CHECK-NEXT:    ret
 entry:
   %0 = load i16, i16* getelementptr inbounds (%struct.s_signed_i16, %struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 1), align 2
   %1 = load i16, i16* getelementptr inbounds (%struct.s_signed_i16, %struct.s_signed_i16* @cost_s_i8_i16, i64 0, i32 2), align 2
@@ -65,11 +83,18 @@ if.end8:                                          ; preds = %if.else, %if.then7,
 }
 
 define void @test_i16_2cmp_unsigned_1() {
-; CHECK-LABEL: test_i16_2cmp_unsigned_1
-; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
-; CHECK-NEXT: b.lo
-; CHECK-NOT: cmp
-; CHECK: ret
+; CHECK-LABEL: test_i16_2cmp_unsigned_1:
+; CHECK:       // %bb.0: // %entry
+; CHECK-NEXT:    adrp x8, :got:cost_u_i16
+; CHECK-NEXT:    ldr x8, [x8, :got_lo12:cost_u_i16]
+; CHECK-NEXT:    ldrh w9, [x8, #2]
+; CHECK-NEXT:    ldrh w10, [x8, #4]
+; CHECK-NEXT:    cmp w9, w10
+; CHECK-NEXT:    b.lo .LBB2_2
+; CHECK-NEXT:  // %bb.1: // %if.end8.sink.split
+; CHECK-NEXT:    strh w9, [x8]
+; CHECK-NEXT:  .LBB2_2: // %if.end8
+; CHECK-NEXT:    ret
 entry:
   %0 = load i16, i16* getelementptr inbounds (%struct.s_unsigned_i16, %struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 1), align 2
   %1 = load i16, i16* getelementptr inbounds (%struct.s_unsigned_i16, %struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 2), align 2
@@ -93,11 +118,21 @@ if.end8:                                          ; preds = %if.else, %if.then7,
 }
 
 define void @test_i16_2cmp_unsigned_2() {
-; CHECK-LABEL: test_i16_2cmp_unsigned_2
-; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
-; CHECK-NEXT: b.hi
-; CHECK-NOT: cmp
-; CHECK: b.hs
+; CHECK-LABEL: test_i16_2cmp_unsigned_2:
+; CHECK:       // %bb.0: // %entry
+; CHECK-NEXT:    adrp x8, :got:cost_u_i16
+; CHECK-NEXT:    ldr x8, [x8, :got_lo12:cost_u_i16]
+; CHECK-NEXT:    ldrh w9, [x8, #2]
+; CHECK-NEXT:    ldrh w10, [x8, #4]
+; CHECK-NEXT:    cmp w9, w10
+; CHECK-NEXT:    b.hi .LBB3_2
+; CHECK-NEXT:  // %bb.1: // %if.else
+; CHECK-NEXT:    mov w9, w10
+; CHECK-NEXT:    b.hs .LBB3_3
+; CHECK-NEXT:  .LBB3_2: // %if.end8.sink.split
+; CHECK-NEXT:    strh w9, [x8]
+; CHECK-NEXT:  .LBB3_3: // %if.end8
+; CHECK-NEXT:    ret
 entry:
   %0 = load i16, i16* getelementptr inbounds (%struct.s_unsigned_i16, %struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 1), align 2
   %1 = load i16, i16* getelementptr inbounds (%struct.s_unsigned_i16, %struct.s_unsigned_i16* @cost_u_i16, i64 0, i32 2), align 2
@@ -130,11 +165,18 @@ if.end8:                                          ; preds = %if.else, %if.then7,
 
 
 define void @test_i8_2cmp_signed_1() {
-; CHECK-LABEL: test_i8_2cmp_signed_1
-; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
-; CHECK-NEXT: b.lt
-; CHECK-NOT: cmp
-; CHECK: ret
+; CHECK-LABEL: test_i8_2cmp_signed_1:
+; CHECK:       // %bb.0: // %entry
+; CHECK-NEXT:    adrp x8, :got:cost_s
+; CHECK-NEXT:    ldr x8, [x8, :got_lo12:cost_s]
+; CHECK-NEXT:    ldrsb w9, [x8, #1]
+; CHECK-NEXT:    ldrsb w10, [x8, #2]
+; CHECK-NEXT:    cmp w9, w10
+; CHECK-NEXT:    b.lt .LBB4_2
+; CHECK-NEXT:  // %bb.1: // %if.end8.sink.split
+; CHECK-NEXT:    strb w9, [x8]
+; CHECK-NEXT:  .LBB4_2: // %if.end8
+; CHECK-NEXT:    ret
 entry:
   %0 = load i8, i8* getelementptr inbounds (%struct.s_signed_i8, %struct.s_signed_i8* @cost_s, i64 0, i32 1), align 2
   %1 = load i8, i8* getelementptr inbounds (%struct.s_signed_i8, %struct.s_signed_i8* @cost_s, i64 0, i32 2), align 2
@@ -158,11 +200,21 @@ if.end8:                                          ; preds = %if.else, %if.then7,
 }
 
 define void @test_i8_2cmp_signed_2() {
-; CHECK-LABEL: test_i8_2cmp_signed_2
-; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
-; CHECK-NEXT: b.gt
-; CHECK-NOT: cmp
-; CHECK: b.ge
+; CHECK-LABEL: test_i8_2cmp_signed_2:
+; CHECK:       // %bb.0: // %entry
+; CHECK-NEXT:    adrp x8, :got:cost_s
+; CHECK-NEXT:    ldr x8, [x8, :got_lo12:cost_s]
+; CHECK-NEXT:    ldrsb w9, [x8, #1]
+; CHECK-NEXT:    ldrsb w10, [x8, #2]
+; CHECK-NEXT:    cmp w9, w10
+; CHECK-NEXT:    b.gt .LBB5_2
+; CHECK-NEXT:  // %bb.1: // %if.else
+; CHECK-NEXT:    mov w9, w10
+; CHECK-NEXT:    b.ge .LBB5_3
+; CHECK-NEXT:  .LBB5_2: // %if.end8.sink.split
+; CHECK-NEXT:    strb w9, [x8]
+; CHECK-NEXT:  .LBB5_3: // %if.end8
+; CHECK-NEXT:    ret
 entry:
   %0 = load i8, i8* getelementptr inbounds (%struct.s_signed_i8, %struct.s_signed_i8* @cost_s, i64 0, i32 1), align 2
   %1 = load i8, i8* getelementptr inbounds (%struct.s_signed_i8, %struct.s_signed_i8* @cost_s, i64 0, i32 2), align 2
@@ -186,11 +238,18 @@ if.end8:                                          ; preds = %if.else, %if.then7,
 }
 
 define void @test_i8_2cmp_unsigned_1() {
-; CHECK-LABEL: test_i8_2cmp_unsigned_1
-; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
-; CHECK-NEXT: b.lo
-; CHECK-NOT: cmp
-; CHECK: ret
+; CHECK-LABEL: test_i8_2cmp_unsigned_1:
+; CHECK:       // %bb.0: // %entry
+; CHECK-NEXT:    adrp x8, :got:cost_u_i8
+; CHECK-NEXT:    ldr x8, [x8, :got_lo12:cost_u_i8]
+; CHECK-NEXT:    ldrb w9, [x8, #1]
+; CHECK-NEXT:    ldrb w10, [x8, #2]
+; CHECK-NEXT:    cmp w9, w10
+; CHECK-NEXT:    b.lo .LBB6_2
+; CHECK-NEXT:  // %bb.1: // %if.end8.sink.split
+; CHECK-NEXT:    strb w9, [x8]
+; CHECK-NEXT:  .LBB6_2: // %if.end8
+; CHECK-NEXT:    ret
 entry:
   %0 = load i8, i8* getelementptr inbounds (%struct.s_unsigned_i8, %struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 1), align 2
   %1 = load i8, i8* getelementptr inbounds (%struct.s_unsigned_i8, %struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 2), align 2
@@ -214,11 +273,21 @@ if.end8:                                          ; preds = %if.else, %if.then7,
 }
 
 define void @test_i8_2cmp_unsigned_2() {
-; CHECK-LABEL: test_i8_2cmp_unsigned_2
-; CHECK: cmp {{w[0-9]+}}, {{w[0-9]+}}
-; CHECK-NEXT: b.hi
-; CHECK-NOT: cmp
-; CHECK: b.hs
+; CHECK-LABEL: test_i8_2cmp_unsigned_2:
+; CHECK:       // %bb.0: // %entry
+; CHECK-NEXT:    adrp x8, :got:cost_u_i8
+; CHECK-NEXT:    ldr x8, [x8, :got_lo12:cost_u_i8]
+; CHECK-NEXT:    ldrb w9, [x8, #1]
+; CHECK-NEXT:    ldrb w10, [x8, #2]
+; CHECK-NEXT:    cmp w9, w10
+; CHECK-NEXT:    b.hi .LBB7_2
+; CHECK-NEXT:  // %bb.1: // %if.else
+; CHECK-NEXT:    mov w9, w10
+; CHECK-NEXT:    b.hs .LBB7_3
+; CHECK-NEXT:  .LBB7_2: // %if.end8.sink.split
+; CHECK-NEXT:    strb w9, [x8]
+; CHECK-NEXT:  .LBB7_3: // %if.end8
+; CHECK-NEXT:    ret
 entry:
   %0 = load i8, i8* getelementptr inbounds (%struct.s_unsigned_i8, %struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 1), align 2
   %1 = load i8, i8* getelementptr inbounds (%struct.s_unsigned_i8, %struct.s_unsigned_i8* @cost_u_i8, i64 0, i32 2), align 2
@@ -247,6 +316,13 @@ if.end8:                                          ; preds = %if.else, %if.then7,
 ; the operand of a set_cc is always a TRUNCATE.
 
 define i1 @foo(float %inl, float %inr) {
+; CHECK-LABEL: foo:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    fcvtzs w8, s0
+; CHECK-NEXT:    fcvtzs w9, s1
+; CHECK-NEXT:    cmp w8, w9
+; CHECK-NEXT:    cset w0, eq
+; CHECK-NEXT:    ret
   %lval = fptosi float %inl to i8
   %rval = fptosi float %inr to i8
   %sum = icmp eq i8 %lval, %rval

diff  --git a/llvm/test/CodeGen/AArch64/typepromotion-cost.ll b/llvm/test/CodeGen/AArch64/typepromotion-cost.ll
new file mode 100644
index 000000000000..f4a8f2ecf58b
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/typepromotion-cost.ll
@@ -0,0 +1,105 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -o - %s -mtriple=aarch64-none-eabi | FileCheck %s --check-prefix=CHECK-O2
+; RUN: llc -o - %s -mtriple=aarch64-none-eabi -O3 | FileCheck %s --check-prefix=CHECK-O3
+
+%struct.S = type { i32, i16 }
+define i32 @needless_promotion(ptr nocapture noundef readonly %S, i64 noundef %red_cost) {
+; CHECK-O2-LABEL: needless_promotion:
+; CHECK-O2:       // %bb.0: // %entry
+; CHECK-O2-NEXT:    ldrsh w8, [x0, #4]
+; CHECK-O2-NEXT:    tbnz w8, #31, .LBB0_3
+; CHECK-O2-NEXT:  // %bb.1: // %lor.rhs
+; CHECK-O2-NEXT:    cbz x1, .LBB0_5
+; CHECK-O2-NEXT:  // %bb.2:
+; CHECK-O2-NEXT:    mov w9, #2
+; CHECK-O2-NEXT:    b .LBB0_4
+; CHECK-O2-NEXT:  .LBB0_3:
+; CHECK-O2-NEXT:    mov w9, #1
+; CHECK-O2-NEXT:  .LBB0_4: // %lor.end.sink.split
+; CHECK-O2-NEXT:    and w8, w8, #0xffff
+; CHECK-O2-NEXT:    cmp w8, w9
+; CHECK-O2-NEXT:    cset w0, eq
+; CHECK-O2-NEXT:    ret
+; CHECK-O2-NEXT:  .LBB0_5:
+; CHECK-O2-NEXT:    mov w0, wzr
+; CHECK-O2-NEXT:    ret
+;
+; CHECK-O3-LABEL: needless_promotion:
+; CHECK-O3:       // %bb.0: // %entry
+; CHECK-O3-NEXT:    ldrsh w8, [x0, #4]
+; CHECK-O3-NEXT:    tbnz w8, #31, .LBB0_3
+; CHECK-O3-NEXT:  // %bb.1: // %lor.rhs
+; CHECK-O3-NEXT:    cbz x1, .LBB0_4
+; CHECK-O3-NEXT:  // %bb.2:
+; CHECK-O3-NEXT:    mov w9, #2
+; CHECK-O3-NEXT:    and w8, w8, #0xffff
+; CHECK-O3-NEXT:    cmp w8, w9
+; CHECK-O3-NEXT:    cset w0, eq
+; CHECK-O3-NEXT:    ret
+; CHECK-O3-NEXT:  .LBB0_3:
+; CHECK-O3-NEXT:    mov w9, #1
+; CHECK-O3-NEXT:    and w8, w8, #0xffff
+; CHECK-O3-NEXT:    cmp w8, w9
+; CHECK-O3-NEXT:    cset w0, eq
+; CHECK-O3-NEXT:    ret
+; CHECK-O3-NEXT:  .LBB0_4:
+; CHECK-O3-NEXT:    mov w0, wzr
+; CHECK-O3-NEXT:    ret
+entry:
+  %ident = getelementptr inbounds %struct.S, ptr %S, i64 0, i32 1
+  %0 = load i16, ptr %ident, align 8
+  %cmp = icmp slt i16 %0, 0
+  br i1 %cmp, label %lor.end.sink.split, label %lor.rhs
+
+lor.rhs:                                          ; preds = %entry
+  %cmp3.not = icmp eq i64 %red_cost, 0
+  br i1 %cmp3.not, label %lor.end, label %lor.end.sink.split
+
+lor.end.sink.split:                               ; preds = %lor.rhs, %entry
+  %.sink12 = phi i16 [ 1, %entry ], [ 2, %lor.rhs ]
+  %cmp1 = icmp eq i16 %0, %.sink12
+  %phi.cast = zext i1 %cmp1 to i32
+  br label %lor.end
+
+lor.end:                                          ; preds = %lor.end.sink.split, %lor.rhs
+  %.shrunk = phi i32 [ 0, %lor.rhs ], [ %phi.cast, %lor.end.sink.split ]
+  ret i32 %.shrunk
+}
+
+define i8 @loopcmp(ptr nocapture noundef readonly %x, i8 noundef %y) {
+; CHECK-O2-LABEL: loopcmp:
+; CHECK-O2:       // %bb.0: // %entry
+; CHECK-O2-NEXT:  .LBB1_1: // %while.cond
+; CHECK-O2-NEXT:    // =>This Inner Loop Header: Depth=1
+; CHECK-O2-NEXT:    ldrb w8, [x0], #1
+; CHECK-O2-NEXT:    cmp w8, w1, uxtb
+; CHECK-O2-NEXT:    b.lo .LBB1_1
+; CHECK-O2-NEXT:  // %bb.2: // %while.end
+; CHECK-O2-NEXT:    mov w0, w8
+; CHECK-O2-NEXT:    ret
+;
+; CHECK-O3-LABEL: loopcmp:
+; CHECK-O3:       // %bb.0: // %entry
+; CHECK-O3-NEXT:    and w9, w1, #0xff
+; CHECK-O3-NEXT:  .LBB1_1: // %while.cond
+; CHECK-O3-NEXT:    // =>This Inner Loop Header: Depth=1
+; CHECK-O3-NEXT:    ldrb w8, [x0], #1
+; CHECK-O3-NEXT:    cmp w8, w9
+; CHECK-O3-NEXT:    b.lo .LBB1_1
+; CHECK-O3-NEXT:  // %bb.2: // %while.end
+; CHECK-O3-NEXT:    mov w0, w8
+; CHECK-O3-NEXT:    ret
+entry:
+  br label %while.cond
+
+while.cond:                                       ; preds = %while.cond, %entry
+  %a.0.in = phi ptr [ %x, %entry ], [ %x.addr.0, %while.cond ]
+  %a.0 = load i8, ptr %a.0.in, align 1
+  %cmp = icmp ult i8 %a.0, %y
+  %x.addr.0 = getelementptr inbounds i8, ptr %a.0.in, i64 1
+  br i1 %cmp, label %while.cond, label %while.end
+
+while.end:                                        ; preds = %while.cond
+  ret i8 %a.0
+}
+


        


More information about the llvm-commits mailing list