]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Add another test for FRM elimination bug [PR118646]
authorVineet Gupta <vineetg@rivosinc.com>
Fri, 24 Jan 2025 21:56:28 +0000 (13:56 -0800)
committerVineet Gupta <vineetg@rivosinc.com>
Mon, 27 Jan 2025 22:04:15 +0000 (14:04 -0800)
The issue is same as PR118103 and fixed by commit 55d288d4ff53
("RISC-V: Make FRM as global register [PR118103]").

Essentially FRM save/restore were getting eliminated because FRM reg
semantics were not being modelled correctly.

In this case it showed up as SPEC2017 527.cam4 runtime aborts in
glibc:round_away() due to non-canonical rounding mode showing up,
"leaking" earlier in the call chain because such rounding mode
save/restore was getting eliminated.

PR target/118646

gcc/testsuite/ChangeLog:
* gfortran.target/riscv/rvv/pr118646.f90 (New Test).

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
gcc/testsuite/gfortran.target/riscv/rvv/pr118646.f90 [new file with mode: 0644]

diff --git a/gcc/testsuite/gfortran.target/riscv/rvv/pr118646.f90 b/gcc/testsuite/gfortran.target/riscv/rvv/pr118646.f90
new file mode 100644 (file)
index 0000000..e2a0343
--- /dev/null
@@ -0,0 +1,48 @@
+! Reduced from SPEC2017 527.cam4 zm_conv.F90
+
+! { dg-do compile }
+! { dg-options "-Ofast -std=legacy -march=rv64gcv_zvl256b_zba_zbb_zbs_zicond -ftree-vectorize -mabi=lp64d" }
+
+module a
+  contains
+subroutine b(f)
+
+   real d(4)
+   integer e(4)
+   integer f(4)
+   real hmax(4)
+   real g(4)
+
+   integer h(4)
+   integer l(4,5)
+   do i = 1,c
+      h(i) = 0
+   end do
+   do k = j  ,1
+      do i = 1,c
+         q = g(i) + hmax(i)
+         if (k >= nint(d(i)) .and. k <= e(i) .and. q > 1.e4) then
+            f(i) = k
+         end if
+      if (k < o ) then
+            if (buoy<= 0.) then
+               l(i,h) = k
+            end if
+         end if
+      end do
+   end do
+   do n = 1,5
+      do k = 1,m
+         do i = 1,c
+            if (k > l(i,n)) then
+               p = r()
+            end if
+         end do
+      end do
+   end do
+end
+end
+
+! { dg-final { scan-assembler-times {frrm\s+[axs][0-9]+} 1 } }
+! { dg-final { scan-assembler-times {fsrmi\s+[01234]} 1 } }
+! { dg-final { scan-assembler-times {fsrm\s+[axs][0-9]+} 1 } }