diff options
author | Thorsten Schütt <schuett@gmail.com> | 2024-03-29 13:38:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-29 13:38:08 +0100 |
commit | 84299df301dc07ea83fa8378051103195c3a7c65 (patch) | |
tree | 8b5960a86b1085df4d4bb219b00b6bdd1abad068 /llvm/test/CodeGen/AArch64 | |
parent | ea707baca2f73d503849d2b7429c7507314bff6b (diff) | |
download | llvm-84299df301dc07ea83fa8378051103195c3a7c65.zip llvm-84299df301dc07ea83fa8378051103195c3a7c65.tar.gz llvm-84299df301dc07ea83fa8378051103195c3a7c65.tar.bz2 |
[GlobalIsel] add trunc flags (#87045)
https://github.com/llvm/llvm-project/pull/85592
Diffstat (limited to 'llvm/test/CodeGen/AArch64')
-rw-r--r-- | llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-trunc.ll | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-trunc.ll b/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-trunc.ll new file mode 100644 index 0000000..d87e9c4 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-trunc.ll @@ -0,0 +1,90 @@ +; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py +; RUN: llc -O0 -mtriple=aarch64-linux-gnu -global-isel -stop-after=irtranslator %s -o - | FileCheck %s + +define i32 @call_trunc_no_flags(i64 %a) { + ; CHECK-LABEL: name: call_trunc_no_flags + ; CHECK: bb.1.entry: + ; CHECK-NEXT: liveins: $x0 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 + ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64) + ; CHECK-NEXT: $w0 = COPY [[TRUNC]](s32) + ; CHECK-NEXT: RET_ReallyLR implicit $w0 +entry: + %result = trunc i64 %a to i32 + ret i32 %result +} + +define i32 @call_trunc_nsw_flags(i64 %a) { + ; CHECK-LABEL: name: call_trunc_nsw_flags + ; CHECK: bb.1.entry: + ; CHECK-NEXT: liveins: $x0 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 + ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = nsw G_TRUNC [[COPY]](s64) + ; CHECK-NEXT: $w0 = COPY [[TRUNC]](s32) + ; CHECK-NEXT: RET_ReallyLR implicit $w0 +entry: + %result = trunc nsw i64 %a to i32 + ret i32 %result +} + +define i32 @call_trunc_nuw_flags(i64 %a) { + ; CHECK-LABEL: name: call_trunc_nuw_flags + ; CHECK: bb.1.entry: + ; CHECK-NEXT: liveins: $x0 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 + ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = nuw G_TRUNC [[COPY]](s64) + ; CHECK-NEXT: $w0 = COPY [[TRUNC]](s32) + ; CHECK-NEXT: RET_ReallyLR implicit $w0 +entry: + %result = trunc nuw i64 %a to i32 + ret i32 %result +} + +define i32 @call_trunc_all_flags(i64 %a) { + ; CHECK-LABEL: name: call_trunc_all_flags + ; CHECK: bb.1.entry: + ; CHECK-NEXT: liveins: $x0 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 + ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = nuw nsw G_TRUNC [[COPY]](s64) + ; CHECK-NEXT: $w0 = COPY [[TRUNC]](s32) + ; CHECK-NEXT: RET_ReallyLR implicit $w0 +entry: + %result = trunc nsw nuw i64 %a to i32 + ret i32 %result +} + +define <2 x i64> @call_trunc_noop_signed_vector(<2 x i64> %a) { + ; CHECK-LABEL: name: call_trunc_noop_signed_vector + ; CHECK: bb.1.entry: + ; CHECK-NEXT: liveins: $q0 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0 + ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(<2 x s32>) = nsw G_TRUNC [[COPY]](<2 x s64>) + ; CHECK-NEXT: [[SEXT:%[0-9]+]]:_(<2 x s64>) = G_SEXT [[TRUNC]](<2 x s32>) + ; CHECK-NEXT: $q0 = COPY [[SEXT]](<2 x s64>) + ; CHECK-NEXT: RET_ReallyLR implicit $q0 +entry: + %truncate = trunc nsw <2 x i64> %a to <2 x i32> + %result = sext <2 x i32> %truncate to <2 x i64> + ret <2 x i64> %result +} + +define <2 x i64> @call_trunc_noop_unsigned_vector(<2 x i64> %a) { + ; CHECK-LABEL: name: call_trunc_noop_unsigned_vector + ; CHECK: bb.1.entry: + ; CHECK-NEXT: liveins: $q0 + ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s64>) = COPY $q0 + ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(<2 x s32>) = nuw G_TRUNC [[COPY]](<2 x s64>) + ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(<2 x s64>) = G_ZEXT [[TRUNC]](<2 x s32>) + ; CHECK-NEXT: $q0 = COPY [[ZEXT]](<2 x s64>) + ; CHECK-NEXT: RET_ReallyLR implicit $q0 +entry: + %truncate = trunc nuw <2 x i64> %a to <2 x i32> + %result = zext <2 x i32> %truncate to <2 x i64> + ret <2 x i64> %result +} |