From 5b91beda826907572c38f02fe87769c6eb46cd2b Mon Sep 17 00:00:00 2001 From: Lucas Steuernagel Date: Wed, 13 Dec 2023 18:09:39 -0300 Subject: [PATCH] Reorganize tests --- llvm/test/CodeGen/SBF/neg_instr_with_sub.ll | 59 ------------- .../CodeGen/SBF/sub_reversed_immediate.ll | 39 +++++++++ .../CodeGen/SBF/sub_reversed_immidiate.ll | 82 ------------------- 3 files changed, 39 insertions(+), 141 deletions(-) delete mode 100644 llvm/test/CodeGen/SBF/neg_instr_with_sub.ll create mode 100644 llvm/test/CodeGen/SBF/sub_reversed_immediate.ll delete mode 100644 llvm/test/CodeGen/SBF/sub_reversed_immidiate.ll diff --git a/llvm/test/CodeGen/SBF/neg_instr_with_sub.ll b/llvm/test/CodeGen/SBF/neg_instr_with_sub.ll deleted file mode 100644 index c574f3dae3e2e4..00000000000000 --- a/llvm/test/CodeGen/SBF/neg_instr_with_sub.ll +++ /dev/null @@ -1,59 +0,0 @@ -; RUN: llc < %s -march=sbf -mattr=+alu32 | FileCheck %s -; -; Source: -; int test_func_64(long * vec, long idx) { -; vec[idx] = -idx; -; return idx; -; } -; -; int test_func_32(int * vec, int idx) { -; vec[idx] = -idx; -; return idx; -; } -; -; Compilation flag: -; clang -S -emit-llvm test.c - -; Function Attrs: noinline nounwind optnone ssp uwtable(sync) -define i32 @test_func_32(ptr noundef %vec, i32 noundef %idx) #0 { -; CHECK-LABEL: test_func_32: -; CHECK: stxw [r10 - 12], w2 -; CHECK: sub32 w2, 0 -; CHECK: stxw [r1 + 0], w2 -entry: - %vec.addr = alloca ptr, align 8 - %idx.addr = alloca i32, align 4 - store ptr %vec, ptr %vec.addr, align 8 - store i32 %idx, ptr %idx.addr, align 4 - %0 = load i32, ptr %idx.addr, align 4 - %sub = sub nsw i32 0, %0 - %1 = load ptr, ptr %vec.addr, align 8 - %2 = load i32, ptr %idx.addr, align 4 - %idxprom = sext i32 %2 to i64 - %arrayidx = getelementptr inbounds i32, ptr %1, i64 %idxprom - store i32 %sub, ptr %arrayidx, align 4 - %3 = load i32, ptr %idx.addr, align 4 - ret i32 %3 -} - -; Function Attrs: noinline nounwind optnone ssp uwtable(sync) -define i32 @test_func_64(ptr noundef %vec, i64 noundef %idx) #0 { -entry: -; CHECK-LABEL: test_func_64: -; CHECK: stxdw [r10 - 16], r2 -; CHECK: sub64 r2, 0 -; CHECK: stxdw [r1 + 0], r2 - %vec.addr = alloca ptr, align 8 - %idx.addr = alloca i64, align 8 - store ptr %vec, ptr %vec.addr, align 8 - store i64 %idx, ptr %idx.addr, align 8 - %0 = load i64, ptr %idx.addr, align 8 - %sub = sub nsw i64 0, %0 - %1 = load ptr, ptr %vec.addr, align 8 - %2 = load i64, ptr %idx.addr, align 8 - %arrayidx = getelementptr inbounds i64, ptr %1, i64 %2 - store i64 %sub, ptr %arrayidx, align 8 - %3 = load i64, ptr %idx.addr, align 8 - %conv = trunc i64 %3 to i32 - ret i32 %conv -} \ No newline at end of file diff --git a/llvm/test/CodeGen/SBF/sub_reversed_immediate.ll b/llvm/test/CodeGen/SBF/sub_reversed_immediate.ll new file mode 100644 index 00000000000000..3a2059f9602b08 --- /dev/null +++ b/llvm/test/CodeGen/SBF/sub_reversed_immediate.ll @@ -0,0 +1,39 @@ +; RUN: llc < %s -march=sbf -mattr=+alu32 | FileCheck %s + + +; Function Attrs: norecurse nounwind readnone +define dso_local i64 @sub_ri_64(i64 %a) #0 { +entry: +; CHECK-LABEL: sub_ri_64: + %sub = sub nsw i64 50, %a +; CHECK: sub64 r{{[0-9]+}}, 50 + ret i64 %sub +} + +; Function Attrs: norecurse nounwind readnone +define dso_local i32 @sub_ri_32(i32 %a) #0 { +entry: +; CHECK-LABEL: sub_ri_32: + %sub = sub nsw i32 50, %a +; CHECK: sub32 w{{[0-9]+}}, 50 + ret i32 %sub +} + + +; Function Attrs: norecurse nounwind readnone +define dso_local i64 @neg_64(i64 %a) #0 { +entry: +; CHECK-LABEL: neg_64: + %sub = sub nsw i64 0, %a +; CHECK: sub64 r{{[0-9]+}}, 0 + ret i64 %sub +} + +; Function Attrs: norecurse nounwind readnone +define dso_local i32 @neg_32(i32 %a) #0 { +entry: +; CHECK-LABEL: neg_32: + %sub = sub nsw i32 0, %a +; CHECK: sub32 w{{[0-9]+}}, 0 + ret i32 %sub +} diff --git a/llvm/test/CodeGen/SBF/sub_reversed_immidiate.ll b/llvm/test/CodeGen/SBF/sub_reversed_immidiate.ll deleted file mode 100644 index 510bdbb481b0e6..00000000000000 --- a/llvm/test/CodeGen/SBF/sub_reversed_immidiate.ll +++ /dev/null @@ -1,82 +0,0 @@ -; RUN: llc < %s -march=sbf -mattr=+alu32 | FileCheck %s -; -; Source: -; void test_func_64(long * vec) { -; vec[0] = 50 - vec[0]; -; vec[1] = vec[3] - vec[2]; -; } -; -; void test_func_32(int * vec) { -; vec[0] = 50 - vec[0]; -; vec[1] = vec[3] - vec[2]; -; } -; -; Compilation flag: -; clang -S -emit-llvm test.c - - -; Function Attrs: noinline nounwind optnone ssp uwtable(sync) -define void @test_func_64(ptr noundef %vec) #0 { -entry: -; CHECK-LABEL: test_func_64: - %vec.addr = alloca ptr, align 8 - store ptr %vec, ptr %vec.addr, align 8 - %0 = load ptr, ptr %vec.addr, align 8 - %arrayidx = getelementptr inbounds i64, ptr %0, i64 0 - %1 = load i64, ptr %arrayidx, align 8 - %sub = sub nsw i64 50, %1 -; CHECK: ldxdw r2, [r1 + 0] -; CHECK: sub64 r2, 50 -; CHECK: stxdw [r1 + 0], r2 - %2 = load ptr, ptr %vec.addr, align 8 - %arrayidx1 = getelementptr inbounds i64, ptr %2, i64 0 - store i64 %sub, ptr %arrayidx1, align 8 - %3 = load ptr, ptr %vec.addr, align 8 - %arrayidx2 = getelementptr inbounds i64, ptr %3, i64 3 - %4 = load i64, ptr %arrayidx2, align 8 - %5 = load ptr, ptr %vec.addr, align 8 - %arrayidx3 = getelementptr inbounds i64, ptr %5, i64 2 - %6 = load i64, ptr %arrayidx3, align 8 - %sub4 = sub nsw i64 %4, %6 -; CHECK: ldxdw r2, [r1 + 16] -; CHECK: ldxdw r3, [r1 + 24] -; CHECK: sub64 r3, r2 -; CHECK: stxdw [r1 + 8], r3 - %7 = load ptr, ptr %vec.addr, align 8 - %arrayidx5 = getelementptr inbounds i64, ptr %7, i64 1 - store i64 %sub4, ptr %arrayidx5, align 8 - ret void -} - -; Function Attrs: noinline nounwind optnone ssp uwtable(sync) -define void @test_func_32(ptr noundef %vec) #0 { -entry: -; CHECK-LABEL: test_func_32: - %vec.addr = alloca ptr, align 8 - store ptr %vec, ptr %vec.addr, align 8 - %0 = load ptr, ptr %vec.addr, align 8 - %arrayidx = getelementptr inbounds i32, ptr %0, i64 0 - %1 = load i32, ptr %arrayidx, align 4 - %sub = sub nsw i32 50, %1 -; CHECK: ldxw w2, [r1 + 0] -; CHECK: sub32 w2, 50 -; CHECK: stxw [r1 + 0], w2 - %2 = load ptr, ptr %vec.addr, align 8 - %arrayidx1 = getelementptr inbounds i32, ptr %2, i64 0 - store i32 %sub, ptr %arrayidx1, align 4 - %3 = load ptr, ptr %vec.addr, align 8 - %arrayidx2 = getelementptr inbounds i32, ptr %3, i64 3 - %4 = load i32, ptr %arrayidx2, align 4 - %5 = load ptr, ptr %vec.addr, align 8 - %arrayidx3 = getelementptr inbounds i32, ptr %5, i64 2 - %6 = load i32, ptr %arrayidx3, align 4 - %sub4 = sub nsw i32 %4, %6 -; CHECK: ldxw w2, [r1 + 8] -; CHECK: ldxw w3, [r1 + 12] -; CHECK: sub32 w3, w2 -; CHECK: stxw [r1 + 4], w3 - %7 = load ptr, ptr %vec.addr, align 8 - %arrayidx5 = getelementptr inbounds i32, ptr %7, i64 1 - store i32 %sub4, ptr %arrayidx5, align 4 - ret void -} \ No newline at end of file