llvm/llvm/test/CodeGen/RISCV/pr58511.ll

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=riscv64 -mattr=+m | FileCheck %s

define i32 @f(i1 %0, i32 %1, ptr %2) {
; CHECK-LABEL: f:
; CHECK:       # %bb.0: # %BB
; CHECK-NEXT:    slli a0, a0, 63
; CHECK-NEXT:    srai a0, a0, 63
; CHECK-NEXT:    lui a3, 4097
; CHECK-NEXT:    addiw a3, a3, -2047
; CHECK-NEXT:    or a0, a0, a3
; CHECK-NEXT:    mul a1, a1, a3
; CHECK-NEXT:    sw a1, 0(a2)
; CHECK-NEXT:    ret
BB:
  %I = select i1 %0, i32 -1, i32 0
  %I1 = mul i32 %1, 16779265
  %I2 = or i32 16779265, %I
  store i32 %I1, ptr %2
  ret i32 %I2
}

define i32 @g(i1 %0, i32 %1, ptr %2) {
; CHECK-LABEL: g:
; CHECK:       # %bb.0: # %BB
; CHECK-NEXT:    andi a0, a0, 1
; CHECK-NEXT:    addi a0, a0, -1
; CHECK-NEXT:    lui a3, 4097
; CHECK-NEXT:    addiw a3, a3, -2047
; CHECK-NEXT:    or a0, a0, a3
; CHECK-NEXT:    mul a1, a1, a3
; CHECK-NEXT:    sw a1, 0(a2)
; CHECK-NEXT:    ret
BB:
  %I = select i1 %0, i32 0, i32 -1
  %I1 = mul i32 %1, 16779265
  %I2 = or i32 16779265, %I
  store i32 %I1, ptr %2
  ret i32 %I2
}

define i32 @h(i1 %0, i32 %1, ptr %2) {
; CHECK-LABEL: h:
; CHECK:       # %bb.0: # %BB
; CHECK-NEXT:    lui a3, 4097
; CHECK-NEXT:    addiw a3, a3, -2047
; CHECK-NEXT:    mul a1, a1, a3
; CHECK-NEXT:    slli a0, a0, 63
; CHECK-NEXT:    srai a0, a0, 63
; CHECK-NEXT:    and a0, a0, a3
; CHECK-NEXT:    sw a1, 0(a2)
; CHECK-NEXT:    ret
BB:
  %I = select i1 %0, i32 -1, i32 0
  %I1 = mul i32 %1, 16779265
  %I2 = and i32 16779265, %I
  store i32 %I1, ptr %2
  ret i32 %I2
}

define i32 @i(i1 %0, i32 %1, ptr %2) {
; CHECK-LABEL: i:
; CHECK:       # %bb.0: # %BB
; CHECK-NEXT:    andi a0, a0, 1
; CHECK-NEXT:    lui a3, 4097
; CHECK-NEXT:    addiw a3, a3, -2047
; CHECK-NEXT:    mul a1, a1, a3
; CHECK-NEXT:    addi a0, a0, -1
; CHECK-NEXT:    and a0, a0, a3
; CHECK-NEXT:    sw a1, 0(a2)
; CHECK-NEXT:    ret
BB:
  %I = select i1 %0, i32 0, i32 -1
  %I1 = mul i32 %1, 16779265
  %I2 = and i32 16779265, %I
  store i32 %I1, ptr %2
  ret i32 %I2
}