llvm/llvm/test/CodeGen/SystemZ/flt-rounds.ll

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=s390x-linux-gnu -verify-machineinstrs < %s | FileCheck %s
; RUN: llc -mtriple=s390x-linux-gnu -verify-machineinstrs -O3 < %s | FileCheck %s

@changed = dso_local global i32 0, align 4

define dso_local signext i32 @test_flt_rounds() nounwind {
; CHECK-LABEL: test_flt_rounds:
; CHECK:       # %bb.0:
; CHECK-NEXT:    efpc %r0
; CHECK-NEXT:    nilf %r0, 3
; CHECK-NEXT:    rxsbg %r0, %r0, 33, 63, 63
; CHECK-NEXT:    xilf %r0, 1
; CHECK-NEXT:    llgfr %r2, %r0
; CHECK-NEXT:    br %r14
  %1 = call i32 @llvm.get.rounding()
  ret i32 %1
}

declare i32 @llvm.get.rounding() nounwind

define dso_local signext i32 @test_order(i32 noundef signext %0) nounwind {
; CHECK-LABEL: test_order:
; CHECK:       # %bb.0:
; CHECK-NEXT:    stmg %r13, %r15, 104(%r15)
; CHECK-NEXT:    aghi %r15, -160
; CHECK-NEXT:    efpc %r13
; CHECK-NEXT:    nilf %r13, 3
; CHECK-NEXT:    rxsbg %r13, %r13, 33, 63, 63
; CHECK-NEXT:    xilf %r13, 1
; CHECK-NEXT:    brasl %r14, fesetround@PLT
; CHECK-NEXT:    efpc %r0
; CHECK-NEXT:    nilf %r0, 3
; CHECK-NEXT:    rxsbg %r0, %r0, 33, 63, 63
; CHECK-NEXT:    xilf %r0, 1
; CHECK-NEXT:    crje %r13, %r0, .LBB1_2
; CHECK-NEXT:  # %bb.1:
; CHECK-NEXT:    lhi %r0, 1
; CHECK-NEXT:    strl %r0, changed
; CHECK-NEXT:  .LBB1_2:
; CHECK-NEXT:    llgfr %r2, %r13
; CHECK-NEXT:    lmg %r13, %r15, 264(%r15)
; CHECK-NEXT:    br %r14
  %2 = call i32 @llvm.get.rounding()
  %3 = call signext i32 @fesetround(i32 noundef signext %0)
  %4 = call i32 @llvm.get.rounding()
  %5 = icmp ne i32 %2, %4
  br i1 %5, label %6, label %7

6:                                               ; preds = %1
  store i32 1, ptr @changed, align 4
  br label %7

7:                                               ; preds = %6, %1
  ret i32 %2
}

declare dso_local signext i32 @fesetround(i32 noundef signext) nounwind