|
From: <sv...@va...> - 2012-09-06 03:22:29
|
florian 2012-09-06 04:22:16 +0100 (Thu, 06 Sep 2012)
New Revision: 12958
Log:
s390: Add a testcase for condition code computation for
convert-to-fixed. See VEX r2516. Part of fixing bugzilla #306054.
Added files:
trunk/none/tests/s390x/rounding-1.c
trunk/none/tests/s390x/rounding-1.stderr.exp
trunk/none/tests/s390x/rounding-1.stdout.exp
trunk/none/tests/s390x/rounding-1.vgtest
Modified directories:
trunk/none/tests/s390x/
Modified files:
trunk/none/tests/s390x/Makefile.am
Modified: trunk/none/tests/s390x/
Added: trunk/none/tests/s390x/rounding-1.vgtest (+1 -0)
===================================================================
--- trunk/none/tests/s390x/rounding-1.vgtest 2012-09-03 22:59:28 +01:00 (rev 12957)
+++ trunk/none/tests/s390x/rounding-1.vgtest 2012-09-06 04:22:16 +01:00 (rev 12958)
@@ -0,0 +1 @@
+prog: rounding-1
Property changed: trunk/none/tests/s390x (+0 -0)
___________________________________________________________________
Name: svn:ignore
- .deps
add
add_EI
add_GE
allexec
and
and_EI
clc
clcle
cvb
cvd
div
ex_clone
ex_sig
flogr
icm
insert
insert_EI
lam_stam
lpr
Makefile
Makefile.in
mul
mul_GE
mvst
or
or_EI
srst
sub
sub_EI
tcxb
xc
xor
xor_EI
stck
stcke
stckf
op_exception
fgx
condloadstore
fold_And16
stfle
op00
cksm
clcl
mvcl
troo
trot
trto
trtt
tr
tre
clrj
clgrj
crj
cgrj
clij
clgij
cij
cgij
cs
csg
cds
cdsg
cu21
cu21_1
cu24
cu24_1
cu42
cu12
cu12_1
cu14
cu14_1
cu41
ecag
fpext
fpext_warn
fpconv
+ .deps
add
add_EI
add_GE
allexec
and
and_EI
clc
clcle
cvb
cvd
div
ex_clone
ex_sig
flogr
icm
insert
insert_EI
lam_stam
lpr
Makefile
Makefile.in
mul
mul_GE
mvst
or
or_EI
srst
sub
sub_EI
tcxb
xc
xor
xor_EI
stck
stcke
stckf
op_exception
fgx
condloadstore
fold_And16
stfle
op00
cksm
clcl
mvcl
troo
trot
trto
trtt
tr
tre
clrj
clgrj
crj
cgrj
clij
clgij
cij
cgij
cs
csg
cds
cdsg
cu21
cu21_1
cu24
cu24_1
cu42
cu12
cu12_1
cu14
cu14_1
cu41
ecag
fpext
fpext_warn
fpconv
rounding-1
Added: trunk/none/tests/s390x/rounding-1.stderr.exp (+2 -0)
===================================================================
--- trunk/none/tests/s390x/rounding-1.stderr.exp 2012-09-03 22:59:28 +01:00 (rev 12957)
+++ trunk/none/tests/s390x/rounding-1.stderr.exp 2012-09-06 04:22:16 +01:00 (rev 12958)
@@ -0,0 +1,2 @@
+
+
Added: trunk/none/tests/s390x/rounding-1.stdout.exp (+4 -0)
===================================================================
--- trunk/none/tests/s390x/rounding-1.stdout.exp 2012-09-03 22:59:28 +01:00 (rev 12957)
+++ trunk/none/tests/s390x/rounding-1.stdout.exp 2012-09-06 04:22:16 +01:00 (rev 12958)
@@ -0,0 +1,4 @@
+cfdbr [->near/even] -2147483648.500000 -> -2147483648 cc = 1
+cfdbr [->0] -2147483648.500000 -> -2147483648 cc = 1
+cfdbr [->+inf] -2147483648.500000 -> -2147483648 cc = 1
+cfdbr [->-inf] -2147483648.500000 -> -2147483648 cc = 3
Added: trunk/none/tests/s390x/rounding-1.c (+64 -0)
===================================================================
--- trunk/none/tests/s390x/rounding-1.c 2012-09-03 22:59:28 +01:00 (rev 12957)
+++ trunk/none/tests/s390x/rounding-1.c 2012-09-06 04:22:16 +01:00 (rev 12958)
@@ -0,0 +1,64 @@
+#include <stdlib.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+/* This testcase is to illustrate that for convert to fixed the condition
+ code depends on the rounding mode. */
+
+const char *
+rtext(unsigned round)
+{
+ switch (round) {
+ case 0: return "[fpc]";
+ case 1: return "[->near/away]";
+ /* 2 is invalid */
+ case 3: return "[prep short]";
+ case 4: return "[->near/even]";
+ case 5: return "[->0]";
+ case 6: return "[->+inf]";
+ case 7: return "[->-inf]";
+ }
+ assert(0);
+}
+
+#define convert_to_int(opcode,src_type,dst_type,dst_fmt,round,value) \
+do { \
+ src_type src = value; \
+ dst_type dst; \
+ unsigned cc; \
+ \
+ __asm__ volatile (opcode " %[dst]," #round ",%[src]\n\t" \
+ "ipm %[cc]\n\t" \
+ "srl %[cc],28\n\t" \
+ : [dst] "=d"(dst), [cc] "=d"(cc) \
+ : [src] "f"(src) \
+ : "cc"); \
+ \
+ printf("%s %-20s %f\t-> %"dst_fmt"\tcc = %u\n", \
+ opcode, rtext(round), src, dst, cc); \
+} while (0)
+
+
+#define cfdbr(round,value) \
+ convert_to_int("cfdbr",double,int32_t,PRId32,round,value)
+
+int main(void)
+{
+ double dval;
+
+ dval = -2147483648.5; // a < MN
+
+ // f64 -> i32
+
+ cfdbr(4, dval); // round to nearest with ties to even
+ cfdbr(5, dval); // round to zero
+ cfdbr(6, dval); // round to +inf
+
+ /* The next invocation needs to give cc=3. It used to give cc=1 when
+ we were considering the to-be-converted value ONLY */
+ cfdbr(7, dval); // round to -inf
+
+ return 0;
+}
Modified: trunk/none/tests/s390x/Makefile.am (+2 -1)
===================================================================
--- trunk/none/tests/s390x/Makefile.am 2012-09-03 22:59:28 +01:00 (rev 12957)
+++ trunk/none/tests/s390x/Makefile.am 2012-09-06 04:22:16 +01:00 (rev 12958)
@@ -8,7 +8,8 @@
op_exception fgx stck stckf stcke stfle cksm mvcl clcl troo \
trto trot trtt tr tre cij cgij clij clgij crj cgrj clrj clgrj \
cs csg cds cdsg cu21 cu21_1 cu24 cu24_1 cu42 cu12 cu12_1 \
- ex_sig ex_clone cu14 cu14_1 cu41 fpconv ecag fpext fpext_warn
+ ex_sig ex_clone cu14 cu14_1 cu41 fpconv ecag fpext fpext_warn \
+ rounding-1
check_PROGRAMS = $(INSN_TESTS) \
allexec \
|