1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2 ; RUN: llc < %s -mtriple=riscv64 -mattr=+v -verify-machineinstrs | FileCheck %s
4 ; Use cttz to test if we properly prove never-zero. There is a very
5 ; simple transform from cttz -> cttz_zero_undef if its operand is
8 ; Even without vscale_range, vscale is always guaranteed to be non-zero.
9 define i32 @vscale_known_nonzero() {
10 ; CHECK-LABEL: vscale_known_nonzero:
12 ; CHECK-NEXT: addi sp, sp, -16
13 ; CHECK-NEXT: .cfi_def_cfa_offset 16
14 ; CHECK-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
15 ; CHECK-NEXT: .cfi_offset ra, -8
16 ; CHECK-NEXT: csrr a0, vlenb
17 ; CHECK-NEXT: srli a0, a0, 3
18 ; CHECK-NEXT: neg a1, a0
19 ; CHECK-NEXT: and a0, a0, a1
20 ; CHECK-NEXT: lui a1, 30667
21 ; CHECK-NEXT: addiw a1, a1, 1329
22 ; CHECK-NEXT: call __muldi3
23 ; CHECK-NEXT: srliw a0, a0, 27
24 ; CHECK-NEXT: lui a1, %hi(.LCPI0_0)
25 ; CHECK-NEXT: addi a1, a1, %lo(.LCPI0_0)
26 ; CHECK-NEXT: add a0, a1, a0
27 ; CHECK-NEXT: lbu a0, 0(a0)
28 ; CHECK-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
29 ; CHECK-NEXT: addi sp, sp, 16
31 %x = call i32 @llvm.vscale()
32 %r = call i32 @llvm.cttz.i32(i32 %x, i1 false)