; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -O0 -mtriple=riscv32 -mattr=+xcvelw -verify-machineinstrs < %s \
; RUN:   | FileCheck %s

declare i32 @llvm.riscv.cv.elw.elw(i8*)

define i32 @test.cv.elw.elw(i8* %a) {
; CHECK-LABEL: test.cv.elw.elw:
; CHECK:       # %bb.0:
; CHECK-NEXT:    cv.elw a0, 0(a0)
; CHECK-NEXT:    ret
  %1 = call i32 @llvm.riscv.cv.elw.elw(i8* %a)
  ret i32 %1
}

define i32 @test.cv.elw.elw2(i8* %a, i32 %b) {
; CHECK-LABEL: test.cv.elw.elw2:
; CHECK:       # %bb.0:
; CHECK-NEXT:    add a0, a1, a0
; CHECK-NEXT:    cv.elw a0, 7(a0)
; CHECK-NEXT:    ret
  %c = add i32 %b, 4
  %d = add i32 %c, 3
  %e = getelementptr i8, i8* %a, i32 %d
  %1 = call i32 @llvm.riscv.cv.elw.elw(i8* %e)
  ret i32 %1
}