[llvm] e114bdf - [NFC][AArch64] More cast cost tests

Sam Parker via llvm-commits llvm-commits at lists.llvm.org
Tue May 12 03:33:19 PDT 2020


Author: Sam Parker
Date: 2020-05-12T11:32:52+01:00
New Revision: e114bdf072d98756de289bfc0f3aefc4e34304ee

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

LOG: [NFC][AArch64] More cast cost tests

Add truncating stores and casts with users.

Added: 
    

Modified: 
    llvm/test/Analysis/CostModel/AArch64/cast.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Analysis/CostModel/AArch64/cast.ll b/llvm/test/Analysis/CostModel/AArch64/cast.ll
index a21bb779e312..d3a4f87a58b6 100644
--- a/llvm/test/Analysis/CostModel/AArch64/cast.ll
+++ b/llvm/test/Analysis/CostModel/AArch64/cast.ll
@@ -1,8 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
 ; RUN: opt -cost-model -analyze -mtriple=aarch64-none-linux-gnueabi %s -o - | FileCheck %s
 
-define i32 @casts() {
-; CHECK-LABEL: 'casts'
+define i32 @casts_no_users() {
+; CHECK-LABEL: 'casts_no_users'
 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %r0 = sext i1 undef to i8
 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %r1 = zext i1 undef to i8
 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %r2 = sext i1 undef to i16
@@ -552,6 +552,53 @@ define i32 @casts() {
   ret i32 undef
 }
 
+define i64 @casts_with_users(i8 %a) {
+; CHECK-LABEL: 'casts_with_users'
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %r0 = sext i8 %a to i16
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %r1 = sext i16 %r0 to i32
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %r2 = sext i32 %r1 to i64
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r3 = trunc i64 %r2 to i32
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r4 = trunc i32 %r3 to i16
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r5 = trunc i16 %r4 to i8
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %r6 = zext i8 %r5 to i16
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %r7 = zext i16 %r6 to i32
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r8 = zext i32 %r7 to i64
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %r9 = zext i8 %r5 to i32
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r10 = trunc i32 %r9 to i8
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r11 = zext i8 %r10 to i64
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r12 = trunc i64 %r11 to i16
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r13 = zext i16 %r12 to i64
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r14 = trunc i64 %r13 to i8
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %r15 = sext i8 %r14 to i32
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r16 = trunc i32 %r15 to i8
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %r17 = sext i8 %r16 to i64
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r18 = trunc i64 %r17 to i16
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %r19 = sext i16 %r18 to i64
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i64 %r19
+;
+  %r0 = sext i8 %a to i16
+  %r1 = sext i16 %r0 to i32
+  %r2 = sext i32 %r1 to i64
+  %r3 = trunc i64 %r2 to i32
+  %r4 = trunc i32 %r3 to i16
+  %r5 = trunc i16 %r4 to i8
+  %r6 = zext i8 %r5 to i16
+  %r7 = zext i16 %r6 to i32
+  %r8 = zext i32 %r7 to i64
+  %r9 = zext i8 %r5 to i32
+  %r10 = trunc i32 %r9 to i8
+  %r11 = zext i8 %r10 to i64
+  %r12 = trunc i64 %r11 to i16
+  %r13 = zext i16 %r12 to i64
+  %r14 = trunc i64 %r13 to i8
+  %r15 = sext i8 %r14 to i32
+  %r16 = trunc i32 %r15 to i8
+  %r17 = sext i8 %r16 to i64
+  %r18 = trunc i64 %r17 to i16
+  %r19 = sext i16 %r18 to i64
+  ret i64 %r19
+}
+
 define i32 @bitcasts() {
 ; CHECK-LABEL: 'bitcasts'
 ; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %a = bitcast i32 undef to i32
@@ -650,3 +697,34 @@ define i32 @load_extends() {
 
   ret i32 undef
 }
+
+define i32 @store_truncs() {
+; CHECK-LABEL: 'store_truncs'
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r0 = trunc i64 undef to i8
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: store i8 %r0, i8* undef
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r1 = trunc i64 undef to i16
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: store i16 %r1, i16* undef
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r2 = trunc i64 undef to i32
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: store i32 %r2, i32* undef
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r3 = trunc i32 undef to i8
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: store i8 %r3, i8* undef
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r4 = trunc i32 undef to i16
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: store i16 %r4, i16* undef
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %r5 = trunc i16 undef to i8
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: store i8 %r5, i8* undef
+; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef
+;
+  %r0 = trunc i64 undef to i8
+  store i8 %r0, i8* undef
+  %r1 = trunc i64 undef to i16
+  store i16 %r1, i16* undef
+  %r2 = trunc i64 undef to i32
+  store i32 %r2, i32* undef
+  %r3 = trunc i32 undef to i8
+  store i8 %r3, i8* undef
+  %r4 = trunc i32 undef to i16
+  store i16 %r4, i16* undef
+  %r5 = trunc i16 undef to i8
+  store i8 %r5, i8* undef
+  ret i32 undef
+}


        


More information about the llvm-commits mailing list