Skip to content

Conversation

JaydeepChauhan14
Copy link
Contributor

@JaydeepChauhan14 JaydeepChauhan14 commented Aug 26, 2025

  • Moved llvm.set.rounding testcases from llvm/test/CodeGen/X86/fpenv.ll to llvm/test/CodeGen/X86/isel-llvm.set.rounding.ll.
  • Added GlobalIsel RUNs as precommit test and will add llvm.set.rounding GISEL implementation PR after this merge.

@llvmbot
Copy link
Member

llvmbot commented Aug 26, 2025

@llvm/pr-subscribers-backend-x86

Author: None (JaydeepChauhan14)

Changes
  • Moved llvm.set.rounding testcases from llvm/test/CodeGen/X86/fpenv.ll to llvm/test/CodeGen/X86/llvm.set.rounding.ll.
  • Added GlobalIsel RUNs too.

Full diff: https://github.com/llvm/llvm-project/pull/155434.diff

2 Files Affected:

  • (modified) llvm/test/CodeGen/X86/fpenv.ll (-238)
  • (added) llvm/test/CodeGen/X86/llvm.set.rounding.ll (+256)
diff --git a/llvm/test/CodeGen/X86/fpenv.ll b/llvm/test/CodeGen/X86/fpenv.ll
index c79e19f07cda5..77eaaa1ca08db 100644
--- a/llvm/test/CodeGen/X86/fpenv.ll
+++ b/llvm/test/CodeGen/X86/fpenv.ll
@@ -11,244 +11,6 @@ declare i32 @llvm.get.fpmode.i32()
 declare void @llvm.set.fpmode.i32(i32 %fpmode)
 declare void @llvm.reset.fpmode()
 
-define void @func_01() nounwind {
-; X86-NOSSE-LABEL: func_01:
-; X86-NOSSE:       # %bb.0:
-; X86-NOSSE-NEXT:    pushl %eax
-; X86-NOSSE-NEXT:    fnstcw (%esp)
-; X86-NOSSE-NEXT:    orb $12, {{[0-9]+}}(%esp)
-; X86-NOSSE-NEXT:    fldcw (%esp)
-; X86-NOSSE-NEXT:    popl %eax
-; X86-NOSSE-NEXT:    retl
-;
-; X86-SSE-LABEL: func_01:
-; X86-SSE:       # %bb.0:
-; X86-SSE-NEXT:    pushl %eax
-; X86-SSE-NEXT:    fnstcw (%esp)
-; X86-SSE-NEXT:    orb $12, {{[0-9]+}}(%esp)
-; X86-SSE-NEXT:    fldcw (%esp)
-; X86-SSE-NEXT:    stmxcsr (%esp)
-; X86-SSE-NEXT:    orb $96, {{[0-9]+}}(%esp)
-; X86-SSE-NEXT:    ldmxcsr (%esp)
-; X86-SSE-NEXT:    popl %eax
-; X86-SSE-NEXT:    retl
-;
-; X64-LABEL: func_01:
-; X64:       # %bb.0:
-; X64-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
-; X64-NEXT:    orb $12, -{{[0-9]+}}(%rsp)
-; X64-NEXT:    fldcw -{{[0-9]+}}(%rsp)
-; X64-NEXT:    stmxcsr -{{[0-9]+}}(%rsp)
-; X64-NEXT:    orb $96, -{{[0-9]+}}(%rsp)
-; X64-NEXT:    ldmxcsr -{{[0-9]+}}(%rsp)
-; X64-NEXT:    retq
-  call void @llvm.set.rounding(i32 0)  ; TowardZero (CW[11-10] = 11)
-  ret void
-}
-
-define void @func_02() nounwind {
-; X86-NOSSE-LABEL: func_02:
-; X86-NOSSE:       # %bb.0:
-; X86-NOSSE-NEXT:    pushl %eax
-; X86-NOSSE-NEXT:    fnstcw (%esp)
-; X86-NOSSE-NEXT:    andb $-13, {{[0-9]+}}(%esp)
-; X86-NOSSE-NEXT:    fldcw (%esp)
-; X86-NOSSE-NEXT:    popl %eax
-; X86-NOSSE-NEXT:    retl
-;
-; X86-SSE-LABEL: func_02:
-; X86-SSE:       # %bb.0:
-; X86-SSE-NEXT:    pushl %eax
-; X86-SSE-NEXT:    fnstcw (%esp)
-; X86-SSE-NEXT:    andb $-13, {{[0-9]+}}(%esp)
-; X86-SSE-NEXT:    fldcw (%esp)
-; X86-SSE-NEXT:    stmxcsr (%esp)
-; X86-SSE-NEXT:    andb $-97, {{[0-9]+}}(%esp)
-; X86-SSE-NEXT:    ldmxcsr (%esp)
-; X86-SSE-NEXT:    popl %eax
-; X86-SSE-NEXT:    retl
-;
-; X64-LABEL: func_02:
-; X64:       # %bb.0:
-; X64-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
-; X64-NEXT:    andb $-13, -{{[0-9]+}}(%rsp)
-; X64-NEXT:    fldcw -{{[0-9]+}}(%rsp)
-; X64-NEXT:    stmxcsr -{{[0-9]+}}(%rsp)
-; X64-NEXT:    andb $-97, -{{[0-9]+}}(%rsp)
-; X64-NEXT:    ldmxcsr -{{[0-9]+}}(%rsp)
-; X64-NEXT:    retq
-  call void @llvm.set.rounding(i32 1)  ; ToNearestTiesToEven (CW[11-10] = 00)
-  ret void
-}
-
-define void @func_03() nounwind {
-; X86-NOSSE-LABEL: func_03:
-; X86-NOSSE:       # %bb.0:
-; X86-NOSSE-NEXT:    pushl %eax
-; X86-NOSSE-NEXT:    fnstcw (%esp)
-; X86-NOSSE-NEXT:    movl $-3073, %eax # imm = 0xF3FF
-; X86-NOSSE-NEXT:    andl (%esp), %eax
-; X86-NOSSE-NEXT:    orl $2048, %eax # imm = 0x800
-; X86-NOSSE-NEXT:    movw %ax, (%esp)
-; X86-NOSSE-NEXT:    fldcw (%esp)
-; X86-NOSSE-NEXT:    popl %eax
-; X86-NOSSE-NEXT:    retl
-;
-; X86-SSE-LABEL: func_03:
-; X86-SSE:       # %bb.0:
-; X86-SSE-NEXT:    pushl %eax
-; X86-SSE-NEXT:    fnstcw (%esp)
-; X86-SSE-NEXT:    movl $-3073, %eax # imm = 0xF3FF
-; X86-SSE-NEXT:    andl (%esp), %eax
-; X86-SSE-NEXT:    orl $2048, %eax # imm = 0x800
-; X86-SSE-NEXT:    movw %ax, (%esp)
-; X86-SSE-NEXT:    fldcw (%esp)
-; X86-SSE-NEXT:    stmxcsr (%esp)
-; X86-SSE-NEXT:    movl $-24577, %eax # imm = 0x9FFF
-; X86-SSE-NEXT:    andl (%esp), %eax
-; X86-SSE-NEXT:    orl $16384, %eax # imm = 0x4000
-; X86-SSE-NEXT:    movl %eax, (%esp)
-; X86-SSE-NEXT:    ldmxcsr (%esp)
-; X86-SSE-NEXT:    popl %eax
-; X86-SSE-NEXT:    retl
-;
-; X64-LABEL: func_03:
-; X64:       # %bb.0:
-; X64-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
-; X64-NEXT:    movl $-3073, %eax # imm = 0xF3FF
-; X64-NEXT:    andl -{{[0-9]+}}(%rsp), %eax
-; X64-NEXT:    orl $2048, %eax # imm = 0x800
-; X64-NEXT:    movw %ax, -{{[0-9]+}}(%rsp)
-; X64-NEXT:    fldcw -{{[0-9]+}}(%rsp)
-; X64-NEXT:    stmxcsr -{{[0-9]+}}(%rsp)
-; X64-NEXT:    movl $-24577, %eax # imm = 0x9FFF
-; X64-NEXT:    andl -{{[0-9]+}}(%rsp), %eax
-; X64-NEXT:    orl $16384, %eax # imm = 0x4000
-; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp)
-; X64-NEXT:    ldmxcsr -{{[0-9]+}}(%rsp)
-; X64-NEXT:    retq
-  call void @llvm.set.rounding(i32 2)  ; Upward (CW[11-10] = 10)
-  ret void
-}
-
-define void @func_04() nounwind {
-; X86-NOSSE-LABEL: func_04:
-; X86-NOSSE:       # %bb.0:
-; X86-NOSSE-NEXT:    pushl %eax
-; X86-NOSSE-NEXT:    fnstcw (%esp)
-; X86-NOSSE-NEXT:    movl $-3073, %eax # imm = 0xF3FF
-; X86-NOSSE-NEXT:    andl (%esp), %eax
-; X86-NOSSE-NEXT:    orl $1024, %eax # imm = 0x400
-; X86-NOSSE-NEXT:    movw %ax, (%esp)
-; X86-NOSSE-NEXT:    fldcw (%esp)
-; X86-NOSSE-NEXT:    popl %eax
-; X86-NOSSE-NEXT:    retl
-;
-; X86-SSE-LABEL: func_04:
-; X86-SSE:       # %bb.0:
-; X86-SSE-NEXT:    pushl %eax
-; X86-SSE-NEXT:    fnstcw (%esp)
-; X86-SSE-NEXT:    movl $-3073, %eax # imm = 0xF3FF
-; X86-SSE-NEXT:    andl (%esp), %eax
-; X86-SSE-NEXT:    orl $1024, %eax # imm = 0x400
-; X86-SSE-NEXT:    movw %ax, (%esp)
-; X86-SSE-NEXT:    fldcw (%esp)
-; X86-SSE-NEXT:    stmxcsr (%esp)
-; X86-SSE-NEXT:    movl $-24577, %eax # imm = 0x9FFF
-; X86-SSE-NEXT:    andl (%esp), %eax
-; X86-SSE-NEXT:    orl $8192, %eax # imm = 0x2000
-; X86-SSE-NEXT:    movl %eax, (%esp)
-; X86-SSE-NEXT:    ldmxcsr (%esp)
-; X86-SSE-NEXT:    popl %eax
-; X86-SSE-NEXT:    retl
-;
-; X64-LABEL: func_04:
-; X64:       # %bb.0:
-; X64-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
-; X64-NEXT:    movl $-3073, %eax # imm = 0xF3FF
-; X64-NEXT:    andl -{{[0-9]+}}(%rsp), %eax
-; X64-NEXT:    orl $1024, %eax # imm = 0x400
-; X64-NEXT:    movw %ax, -{{[0-9]+}}(%rsp)
-; X64-NEXT:    fldcw -{{[0-9]+}}(%rsp)
-; X64-NEXT:    stmxcsr -{{[0-9]+}}(%rsp)
-; X64-NEXT:    movl $-24577, %eax # imm = 0x9FFF
-; X64-NEXT:    andl -{{[0-9]+}}(%rsp), %eax
-; X64-NEXT:    orl $8192, %eax # imm = 0x2000
-; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp)
-; X64-NEXT:    ldmxcsr -{{[0-9]+}}(%rsp)
-; X64-NEXT:    retq
-  call void @llvm.set.rounding(i32 3)  ; Downward (CW[11-10] = 01)
-  ret void
-}
-
-define void @func_05(i32 %x) nounwind {
-; X86-NOSSE-LABEL: func_05:
-; X86-NOSSE:       # %bb.0:
-; X86-NOSSE-NEXT:    pushl %eax
-; X86-NOSSE-NEXT:    movl {{[0-9]+}}(%esp), %eax
-; X86-NOSSE-NEXT:    leal 4(%eax,%eax), %ecx
-; X86-NOSSE-NEXT:    movl $201, %eax
-; X86-NOSSE-NEXT:    # kill: def $cl killed $cl killed $ecx
-; X86-NOSSE-NEXT:    shll %cl, %eax
-; X86-NOSSE-NEXT:    andl $3072, %eax # imm = 0xC00
-; X86-NOSSE-NEXT:    fnstcw (%esp)
-; X86-NOSSE-NEXT:    movl $-3073, %ecx # imm = 0xF3FF
-; X86-NOSSE-NEXT:    andl (%esp), %ecx
-; X86-NOSSE-NEXT:    orl %eax, %ecx
-; X86-NOSSE-NEXT:    movw %cx, (%esp)
-; X86-NOSSE-NEXT:    fldcw (%esp)
-; X86-NOSSE-NEXT:    popl %eax
-; X86-NOSSE-NEXT:    retl
-;
-; X86-SSE-LABEL: func_05:
-; X86-SSE:       # %bb.0:
-; X86-SSE-NEXT:    pushl %eax
-; X86-SSE-NEXT:    movl {{[0-9]+}}(%esp), %eax
-; X86-SSE-NEXT:    leal 4(%eax,%eax), %ecx
-; X86-SSE-NEXT:    movl $201, %eax
-; X86-SSE-NEXT:    # kill: def $cl killed $cl killed $ecx
-; X86-SSE-NEXT:    shll %cl, %eax
-; X86-SSE-NEXT:    andl $3072, %eax # imm = 0xC00
-; X86-SSE-NEXT:    fnstcw (%esp)
-; X86-SSE-NEXT:    movl $-3073, %ecx # imm = 0xF3FF
-; X86-SSE-NEXT:    andl (%esp), %ecx
-; X86-SSE-NEXT:    orl %eax, %ecx
-; X86-SSE-NEXT:    movw %cx, (%esp)
-; X86-SSE-NEXT:    fldcw (%esp)
-; X86-SSE-NEXT:    stmxcsr (%esp)
-; X86-SSE-NEXT:    movl $-24577, %ecx # imm = 0x9FFF
-; X86-SSE-NEXT:    andl (%esp), %ecx
-; X86-SSE-NEXT:    leal (%ecx,%eax,8), %eax
-; X86-SSE-NEXT:    movl %eax, (%esp)
-; X86-SSE-NEXT:    ldmxcsr (%esp)
-; X86-SSE-NEXT:    popl %eax
-; X86-SSE-NEXT:    retl
-;
-; X64-LABEL: func_05:
-; X64:       # %bb.0:
-; X64-NEXT:    # kill: def $edi killed $edi def $rdi
-; X64-NEXT:    leal 4(%rdi,%rdi), %ecx
-; X64-NEXT:    movl $201, %eax
-; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
-; X64-NEXT:    shll %cl, %eax
-; X64-NEXT:    andl $3072, %eax # imm = 0xC00
-; X64-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
-; X64-NEXT:    movl $-3073, %ecx # imm = 0xF3FF
-; X64-NEXT:    andl -{{[0-9]+}}(%rsp), %ecx
-; X64-NEXT:    orl %eax, %ecx
-; X64-NEXT:    movw %cx, -{{[0-9]+}}(%rsp)
-; X64-NEXT:    fldcw -{{[0-9]+}}(%rsp)
-; X64-NEXT:    stmxcsr -{{[0-9]+}}(%rsp)
-; X64-NEXT:    movl $-24577, %ecx # imm = 0x9FFF
-; X64-NEXT:    andl -{{[0-9]+}}(%rsp), %ecx
-; X64-NEXT:    leal (%rcx,%rax,8), %eax
-; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp)
-; X64-NEXT:    ldmxcsr -{{[0-9]+}}(%rsp)
-; X64-NEXT:    retq
-  call void @llvm.set.rounding(i32 %x)  ; Downward
-  ret void
-}
-
 define void @get_fpenv_01(ptr %ptr) #0 {
 ; X86-NOSSE-LABEL: get_fpenv_01:
 ; X86-NOSSE:       # %bb.0: # %entry
diff --git a/llvm/test/CodeGen/X86/llvm.set.rounding.ll b/llvm/test/CodeGen/X86/llvm.set.rounding.ll
new file mode 100644
index 0000000000000..07e11393ab83d
--- /dev/null
+++ b/llvm/test/CodeGen/X86/llvm.set.rounding.ll
@@ -0,0 +1,256 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=-sse -verify-machineinstrs < %s | FileCheck %s -check-prefixes=NOSSE,SDAG-X86-NOSSE
+; RUN: llc -mtriple=i686-unknown-linux-gnu -global-isel=1 -global-isel-abort=2 -mattr=-sse -verify-machineinstrs < %s | FileCheck %s -check-prefixes=NOSSE,GISEL-X86-NOSSE
+; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+sse -verify-machineinstrs < %s | FileCheck %s -check-prefixes=X86-SSE,SDAG-X86-SSE
+; RUN: llc -mtriple=i686-unknown-linux-gnu -global-isel=1 -global-isel-abort=2 -mattr=+sse -verify-machineinstrs < %s | FileCheck %s -check-prefixes=X86-SSE,GISEL-X86-SSE
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -verify-machineinstrs < %s | FileCheck %s -check-prefixes=X64,SDAG-X64
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -global-isel=1 -global-isel-abort=2 -verify-machineinstrs < %s | FileCheck %s -check-prefixes=X64,GISEL-X64
+
+declare void @llvm.set.rounding(i32 %x)
+
+define void @func_01() nounwind {
+; NOSSE-LABEL: func_01:
+; NOSSE:       # %bb.0:
+; NOSSE-NEXT:    pushl %eax
+; NOSSE-NEXT:    fnstcw (%esp)
+; NOSSE-NEXT:    orb $12, {{[0-9]+}}(%esp)
+; NOSSE-NEXT:    fldcw (%esp)
+; NOSSE-NEXT:    popl %eax
+; NOSSE-NEXT:    retl
+;
+; X86-SSE-LABEL: func_01:
+; X86-SSE:       # %bb.0:
+; X86-SSE-NEXT:    pushl %eax
+; X86-SSE-NEXT:    fnstcw (%esp)
+; X86-SSE-NEXT:    orb $12, {{[0-9]+}}(%esp)
+; X86-SSE-NEXT:    fldcw (%esp)
+; X86-SSE-NEXT:    stmxcsr (%esp)
+; X86-SSE-NEXT:    orb $96, {{[0-9]+}}(%esp)
+; X86-SSE-NEXT:    ldmxcsr (%esp)
+; X86-SSE-NEXT:    popl %eax
+; X86-SSE-NEXT:    retl
+;
+; X64-LABEL: func_01:
+; X64:       # %bb.0:
+; X64-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
+; X64-NEXT:    orb $12, -{{[0-9]+}}(%rsp)
+; X64-NEXT:    fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT:    stmxcsr -{{[0-9]+}}(%rsp)
+; X64-NEXT:    orb $96, -{{[0-9]+}}(%rsp)
+; X64-NEXT:    ldmxcsr -{{[0-9]+}}(%rsp)
+; X64-NEXT:    retq
+  call void @llvm.set.rounding(i32 0)  ; TowardZero (CW[11-10] = 11)
+  ret void
+}
+
+define void @func_02() nounwind {
+; NOSSE-LABEL: func_02:
+; NOSSE:       # %bb.0:
+; NOSSE-NEXT:    pushl %eax
+; NOSSE-NEXT:    fnstcw (%esp)
+; NOSSE-NEXT:    andb $-13, {{[0-9]+}}(%esp)
+; NOSSE-NEXT:    fldcw (%esp)
+; NOSSE-NEXT:    popl %eax
+; NOSSE-NEXT:    retl
+;
+; X86-SSE-LABEL: func_02:
+; X86-SSE:       # %bb.0:
+; X86-SSE-NEXT:    pushl %eax
+; X86-SSE-NEXT:    fnstcw (%esp)
+; X86-SSE-NEXT:    andb $-13, {{[0-9]+}}(%esp)
+; X86-SSE-NEXT:    fldcw (%esp)
+; X86-SSE-NEXT:    stmxcsr (%esp)
+; X86-SSE-NEXT:    andb $-97, {{[0-9]+}}(%esp)
+; X86-SSE-NEXT:    ldmxcsr (%esp)
+; X86-SSE-NEXT:    popl %eax
+; X86-SSE-NEXT:    retl
+;
+; X64-LABEL: func_02:
+; X64:       # %bb.0:
+; X64-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
+; X64-NEXT:    andb $-13, -{{[0-9]+}}(%rsp)
+; X64-NEXT:    fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT:    stmxcsr -{{[0-9]+}}(%rsp)
+; X64-NEXT:    andb $-97, -{{[0-9]+}}(%rsp)
+; X64-NEXT:    ldmxcsr -{{[0-9]+}}(%rsp)
+; X64-NEXT:    retq
+  call void @llvm.set.rounding(i32 1)  ; ToNearestTiesToEven (CW[11-10] = 00)
+  ret void
+}
+
+define void @func_03() nounwind {
+; NOSSE-LABEL: func_03:
+; NOSSE:       # %bb.0:
+; NOSSE-NEXT:    pushl %eax
+; NOSSE-NEXT:    fnstcw (%esp)
+; NOSSE-NEXT:    movl $-3073, %eax # imm = 0xF3FF
+; NOSSE-NEXT:    andl (%esp), %eax
+; NOSSE-NEXT:    orl $2048, %eax # imm = 0x800
+; NOSSE-NEXT:    movw %ax, (%esp)
+; NOSSE-NEXT:    fldcw (%esp)
+; NOSSE-NEXT:    popl %eax
+; NOSSE-NEXT:    retl
+;
+; X86-SSE-LABEL: func_03:
+; X86-SSE:       # %bb.0:
+; X86-SSE-NEXT:    pushl %eax
+; X86-SSE-NEXT:    fnstcw (%esp)
+; X86-SSE-NEXT:    movl $-3073, %eax # imm = 0xF3FF
+; X86-SSE-NEXT:    andl (%esp), %eax
+; X86-SSE-NEXT:    orl $2048, %eax # imm = 0x800
+; X86-SSE-NEXT:    movw %ax, (%esp)
+; X86-SSE-NEXT:    fldcw (%esp)
+; X86-SSE-NEXT:    stmxcsr (%esp)
+; X86-SSE-NEXT:    movl $-24577, %eax # imm = 0x9FFF
+; X86-SSE-NEXT:    andl (%esp), %eax
+; X86-SSE-NEXT:    orl $16384, %eax # imm = 0x4000
+; X86-SSE-NEXT:    movl %eax, (%esp)
+; X86-SSE-NEXT:    ldmxcsr (%esp)
+; X86-SSE-NEXT:    popl %eax
+; X86-SSE-NEXT:    retl
+;
+; X64-LABEL: func_03:
+; X64:       # %bb.0:
+; X64-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
+; X64-NEXT:    movl $-3073, %eax # imm = 0xF3FF
+; X64-NEXT:    andl -{{[0-9]+}}(%rsp), %eax
+; X64-NEXT:    orl $2048, %eax # imm = 0x800
+; X64-NEXT:    movw %ax, -{{[0-9]+}}(%rsp)
+; X64-NEXT:    fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT:    stmxcsr -{{[0-9]+}}(%rsp)
+; X64-NEXT:    movl $-24577, %eax # imm = 0x9FFF
+; X64-NEXT:    andl -{{[0-9]+}}(%rsp), %eax
+; X64-NEXT:    orl $16384, %eax # imm = 0x4000
+; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp)
+; X64-NEXT:    ldmxcsr -{{[0-9]+}}(%rsp)
+; X64-NEXT:    retq
+  call void @llvm.set.rounding(i32 2)  ; Upward (CW[11-10] = 10)
+  ret void
+}
+
+define void @func_04() nounwind {
+; NOSSE-LABEL: func_04:
+; NOSSE:       # %bb.0:
+; NOSSE-NEXT:    pushl %eax
+; NOSSE-NEXT:    fnstcw (%esp)
+; NOSSE-NEXT:    movl $-3073, %eax # imm = 0xF3FF
+; NOSSE-NEXT:    andl (%esp), %eax
+; NOSSE-NEXT:    orl $1024, %eax # imm = 0x400
+; NOSSE-NEXT:    movw %ax, (%esp)
+; NOSSE-NEXT:    fldcw (%esp)
+; NOSSE-NEXT:    popl %eax
+; NOSSE-NEXT:    retl
+;
+; X86-SSE-LABEL: func_04:
+; X86-SSE:       # %bb.0:
+; X86-SSE-NEXT:    pushl %eax
+; X86-SSE-NEXT:    fnstcw (%esp)
+; X86-SSE-NEXT:    movl $-3073, %eax # imm = 0xF3FF
+; X86-SSE-NEXT:    andl (%esp), %eax
+; X86-SSE-NEXT:    orl $1024, %eax # imm = 0x400
+; X86-SSE-NEXT:    movw %ax, (%esp)
+; X86-SSE-NEXT:    fldcw (%esp)
+; X86-SSE-NEXT:    stmxcsr (%esp)
+; X86-SSE-NEXT:    movl $-24577, %eax # imm = 0x9FFF
+; X86-SSE-NEXT:    andl (%esp), %eax
+; X86-SSE-NEXT:    orl $8192, %eax # imm = 0x2000
+; X86-SSE-NEXT:    movl %eax, (%esp)
+; X86-SSE-NEXT:    ldmxcsr (%esp)
+; X86-SSE-NEXT:    popl %eax
+; X86-SSE-NEXT:    retl
+;
+; X64-LABEL: func_04:
+; X64:       # %bb.0:
+; X64-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
+; X64-NEXT:    movl $-3073, %eax # imm = 0xF3FF
+; X64-NEXT:    andl -{{[0-9]+}}(%rsp), %eax
+; X64-NEXT:    orl $1024, %eax # imm = 0x400
+; X64-NEXT:    movw %ax, -{{[0-9]+}}(%rsp)
+; X64-NEXT:    fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT:    stmxcsr -{{[0-9]+}}(%rsp)
+; X64-NEXT:    movl $-24577, %eax # imm = 0x9FFF
+; X64-NEXT:    andl -{{[0-9]+}}(%rsp), %eax
+; X64-NEXT:    orl $8192, %eax # imm = 0x2000
+; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp)
+; X64-NEXT:    ldmxcsr -{{[0-9]+}}(%rsp)
+; X64-NEXT:    retq
+  call void @llvm.set.rounding(i32 3)  ; Downward (CW[11-10] = 01)
+  ret void
+}
+
+define void @func_05(i32 %x) nounwind {
+; NOSSE-LABEL: func_05:
+; NOSSE:       # %bb.0:
+; NOSSE-NEXT:    pushl %eax
+; NOSSE-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; NOSSE-NEXT:    leal 4(%eax,%eax), %ecx
+; NOSSE-NEXT:    movl $201, %eax
+; NOSSE-NEXT:    # kill: def $cl killed $cl killed $ecx
+; NOSSE-NEXT:    shll %cl, %eax
+; NOSSE-NEXT:    andl $3072, %eax # imm = 0xC00
+; NOSSE-NEXT:    fnstcw (%esp)
+; NOSSE-NEXT:    movl $-3073, %ecx # imm = 0xF3FF
+; NOSSE-NEXT:    andl (%esp), %ecx
+; NOSSE-NEXT:    orl %eax, %ecx
+; NOSSE-NEXT:    movw %cx, (%esp)
+; NOSSE-NEXT:    fldcw (%esp)
+; NOSSE-NEXT:    popl %eax
+; NOSSE-NEXT:    retl
+;
+; X86-SSE-LABEL: func_05:
+; X86-SSE:       # %bb.0:
+; X86-SSE-NEXT:    pushl %eax
+; X86-SSE-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-SSE-NEXT:    leal 4(%eax,%eax), %ecx
+; X86-SSE-NEXT:    movl $201, %eax
+; X86-SSE-NEXT:    # kill: def $cl killed $cl killed $ecx
+; X86-SSE-NEXT:    shll %cl, %eax
+; X86-SSE-NEXT:    andl $3072, %eax # imm = 0xC00
+; X86-SSE-NEXT:    fnstcw (%esp)
+; X86-SSE-NEXT:    movl $-3073, %ecx # imm = 0xF3FF
+; X86-SSE-NEXT:    andl (%esp), %ecx
+; X86-SSE-NEXT:    orl %eax, %ecx
+; X86-SSE-NEXT:    movw %cx, (%esp)
+; X86-SSE-NEXT:    fldcw (%esp)
+; X86-SSE-NEXT:    stmxcsr (%esp)
+; X86-SSE-NEXT:    movl $-24577, %ecx # imm = 0x9FFF
+; X86-SSE-NEXT:    andl (%esp), %ecx
+; X86-SSE-NEXT:    leal (%ecx,%eax,8), %eax
+; X86-SSE-NEXT:    movl %eax, (%esp)
+; X86-SSE-NEXT:    ldmxcsr (%esp)
+; X86-SSE-NEXT:    popl %eax
+; X86-SSE-NEXT:    retl
+;
+; X64-LABEL: func_05:
+; X64:       # %bb.0:
+; X64-NEXT:    # kill: def $edi killed $edi def $rdi
+; X64-NEXT:    leal 4(%rdi,%rdi), %ecx
+; X64-NEXT:    movl $201, %eax
+; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
+; X64-NEXT:    shll %cl, %eax
+; X64-NEXT:    andl $3072, %eax # imm = 0xC00
+; X64-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
+; X64-NEXT:    movl $-3073, %ecx # imm = 0xF3FF
+; X64-NEXT:    andl -{{[0-9]+}}(%rsp), %ecx
+; X64-NEXT:    orl %eax, %ecx
+; X64-NEXT:    movw %cx, -{{[0-9]+}}(%rsp)
+; X64-NEXT:    fldcw -{{[0-9]+}}(%rsp)
+; X64-NEXT:    stmxcsr -{{[0-9]+}}(%rsp)
+; X64-NEXT:    movl $-24577, %ecx # imm = 0x9FFF
+; X64-NEXT:    andl -{{[0-9]+}}(%rsp), %ecx
+; X64-NEXT:    leal (%rcx,%rax,8), %eax
+; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp)
+; X64-NEXT:    ldmxcsr -{{[0-9]+}}(%rsp)
+; X64-NEXT:    retq
+  call void @llvm.set.rounding(i32 %x)  ; Downward
+  ret void
+}
+
+attributes #0 = { nounwind "use-soft-float"="true" }
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; GISEL-X64: {{.*}}
+; GISEL-X86-NOSSE: {{.*}}
+; GISEL-X86-SSE: {{.*}}
+; SDAG-X64: {{.*}}
+; SDAG-X86-NOSSE: {{.*}}
+; SDAG-X86-SSE: {{.*}}

@JaydeepChauhan14
Copy link
Contributor Author

@arsenm, @RKSimon, @e-kud please review PR.

@e-kud e-kud requested review from arsenm, RKSimon and e-kud August 27, 2025 00:52
Copy link
Contributor

@e-kud e-kud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failures look unrelated:

lldb-api :: lang/cpp/libcxx-internals-recognizer/TestLibcxxInternalsRecognizer.py
LLVM :: CodeGen/AMDGPU/llvm.amdgcn.rcp.bf16.ll

@JaydeepChauhan14 maybe update the branch?

@@ -0,0 +1,256 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=-sse -verify-machineinstrs < %s | FileCheck %s -check-prefixes=NOSSE,SDAG-X86-NOSSE
; RUN: llc -mtriple=i686-unknown-linux-gnu -global-isel=1 -global-isel-abort=2 -mattr=-sse -verify-machineinstrs < %s | FileCheck %s -check-prefixes=NOSSE,GISEL-X86-NOSSE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about fastisel?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might as well rename it isel-llvm.set.rounding.ll and match the isel test coverage in the other isel-* test files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Collaborator

@RKSimon RKSimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update the summary to account for the new filename

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants