xref: /llvm-project/llvm/test/CodeGen/RISCV/readsteadycounter.ll (revision b8ed69ecc01385c03844e8fa05ba418a5670d322)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
3; RUN:   | FileCheck -check-prefix=RV32I %s
4; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
5; RUN:   | FileCheck -check-prefix=RV64I %s
6
7; Verify that we lower @llvm.readsteadycounter() correctly.
8
9declare i64 @llvm.readsteadycounter()
10
11define i64 @test_builtin_readsteadycounter() nounwind {
12; RV32I-LABEL: test_builtin_readsteadycounter:
13; RV32I:       # %bb.0:
14; RV32I-NEXT:  .LBB0_1: # =>This Inner Loop Header: Depth=1
15; RV32I-NEXT:    rdtimeh a1
16; RV32I-NEXT:    rdtime a0
17; RV32I-NEXT:    rdtimeh a2
18; RV32I-NEXT:    bne a1, a2, .LBB0_1
19; RV32I-NEXT:  # %bb.2:
20; RV32I-NEXT:    ret
21;
22; RV64I-LABEL: test_builtin_readsteadycounter:
23; RV64I:       # %bb.0:
24; RV64I-NEXT:    rdtime a0
25; RV64I-NEXT:    ret
26  %1 = tail call i64 @llvm.readsteadycounter()
27  ret i64 %1
28}
29