Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
tests/tcg/s390x: Test CLGEBR and CGEBRA
Add a small test to prevent regressions. Tested-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Message-Id: <20230724082032.66864-10-iii@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /* | ||
| * Test the CGEBRA instruction. | ||
| * | ||
| * SPDX-License-Identifier: GPL-2.0-or-later | ||
| */ | ||
| #include <assert.h> | ||
| #include <fenv.h> | ||
| #include <stdlib.h> | ||
|
|
||
| int main(void) | ||
| { | ||
| float r2 = 1E+300; | ||
| long long r1; | ||
| int cc; | ||
|
|
||
| feclearexcept(FE_ALL_EXCEPT); | ||
| asm("cgebra %[r1],%[m3],%[r2],%[m4]\n" | ||
| "ipm %[cc]\n" | ||
| : [r1] "=r" (r1) | ||
| , [cc] "=r" (cc) | ||
| : [m3] "i" (5) /* round toward 0 */ | ||
| , [r2] "f" (r2) | ||
| , [m4] "i" (8) /* bit 0 is set, but must be ignored; XxC is not set */ | ||
| : "cc"); | ||
| cc >>= 28; | ||
|
|
||
| assert(r1 == 0x7fffffffffffffffLL); | ||
| assert(cc == 3); | ||
| assert(fetestexcept(FE_ALL_EXCEPT) == (FE_INVALID | FE_INEXACT)); | ||
|
|
||
| return EXIT_SUCCESS; | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /* | ||
| * Test the CLGEBR instruction. | ||
| * | ||
| * SPDX-License-Identifier: GPL-2.0-or-later | ||
| */ | ||
| #include <assert.h> | ||
| #include <fenv.h> | ||
| #include <stdlib.h> | ||
|
|
||
| int main(void) | ||
| { | ||
| float r2 = -1; | ||
| long long r1; | ||
| int cc; | ||
|
|
||
| feclearexcept(FE_ALL_EXCEPT); | ||
| asm("clgebr %[r1],%[m3],%[r2],%[m4]\n" | ||
| "ipm %[cc]\n" | ||
| : [r1] "=r" (r1) | ||
| , [cc] "=r" (cc) | ||
| : [m3] "i" (5) /* round toward 0 */ | ||
| , [r2] "f" (r2) | ||
| , [m4] "i" (8) /* bit 0 is set, but must be ignored; XxC is not set */ | ||
| : "cc"); | ||
| cc >>= 28; | ||
|
|
||
| assert(r1 == 0); | ||
| assert(cc == 3); | ||
| assert(fetestexcept(FE_ALL_EXCEPT) == (FE_INVALID | FE_INEXACT)); | ||
|
|
||
| return EXIT_SUCCESS; | ||
| } |