[PATCH 01/16] cmp: adapt testcase for compares' canonicalization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The current testcase, because it's just checking test-linearize's
output as-is, is very sensitive to small simplification changes.

Fix this by changing the tests into equivalent tests and then just
checking that these tests return '1'. This allows to test only what
really matters for canonicalization and make these tests very robust.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 validation/optim/canonical-cmp.c | 125 ++++---------------------------
 1 file changed, 14 insertions(+), 111 deletions(-)

diff --git a/validation/optim/canonical-cmp.c b/validation/optim/canonical-cmp.c
index e0ca7db36368..9b930b1cbeaa 100644
--- a/validation/optim/canonical-cmp.c
+++ b/validation/optim/canonical-cmp.c
@@ -1,124 +1,27 @@
 typedef	  signed int	sint;
 typedef	unsigned int	uint;
 
-sint seq(sint p, sint a) { return (123 == p) ? a : 0; }
-sint sne(sint p, sint a) { return (123 != p) ? a : 0; }
+sint seq(sint p, sint a) { return (123 == p) == (p == 123); }
+sint sne(sint p, sint a) { return (123 != p) == (p != 123); }
 
-sint slt(sint p, sint a) { return (123 >  p) ? a : 0; }
-sint sle(sint p, sint a) { return (123 >= p) ? a : 0; }
-sint sge(sint p, sint a) { return (123 <= p) ? a : 0; }
-sint sgt(sint p, sint a) { return (123 <  p) ? a : 0; }
+sint slt(sint p, sint a) { return (123 >  p) == (p <  123); }
+sint sle(sint p, sint a) { return (123 >= p) == (p <= 123); }
+sint sge(sint p, sint a) { return (123 <= p) == (p >= 123); }
+sint sgt(sint p, sint a) { return (123 <  p) == (p >  123); }
 
-uint ueq(uint p, uint a) { return (123 == p) ? a : 0; }
-uint une(uint p, uint a) { return (123 != p) ? a : 0; }
+uint ueq(uint p, uint a) { return (123 == p) == (p == 123); }
+uint une(uint p, uint a) { return (123 != p) == (p != 123); }
 
-uint ubt(uint p, uint a) { return (123 >  p) ? a : 0; }
-uint ube(uint p, uint a) { return (123 >= p) ? a : 0; }
-uint uae(uint p, uint a) { return (123 <= p) ? a : 0; }
-uint uat(uint p, uint a) { return (123 <  p) ? a : 0; }
+uint ubt(uint p, uint a) { return (123 >  p) == (p <  123); }
+uint ube(uint p, uint a) { return (123 >= p) == (p <= 123); }
+uint uae(uint p, uint a) { return (123 <= p) == (p >= 123); }
+uint uat(uint p, uint a) { return (123 <  p) == (p >  123); }
 
 /*
  * check-name: canonical-cmp
+ * check-description: check that constants move rightside
  * check-command: test-linearize -Wno-decl $file
  *
+ * check-output-ignore
  * check-output-excludes: \\$123,
- *
- * check-output-start
-seq:
-.L0:
-	<entry-point>
-	seteq.32    %r3 <- %arg1, $123
-	select.32   %r4 <- %r3, %arg2, $0
-	ret.32      %r4
-
-
-sne:
-.L2:
-	<entry-point>
-	setne.32    %r8 <- %arg1, $123
-	select.32   %r9 <- %r8, %arg2, $0
-	ret.32      %r9
-
-
-slt:
-.L4:
-	<entry-point>
-	setlt.32    %r13 <- %arg1, $123
-	select.32   %r14 <- %r13, %arg2, $0
-	ret.32      %r14
-
-
-sle:
-.L6:
-	<entry-point>
-	setle.32    %r18 <- %arg1, $123
-	select.32   %r19 <- %r18, %arg2, $0
-	ret.32      %r19
-
-
-sge:
-.L8:
-	<entry-point>
-	setge.32    %r23 <- %arg1, $123
-	select.32   %r24 <- %r23, %arg2, $0
-	ret.32      %r24
-
-
-sgt:
-.L10:
-	<entry-point>
-	setgt.32    %r28 <- %arg1, $123
-	select.32   %r29 <- %r28, %arg2, $0
-	ret.32      %r29
-
-
-ueq:
-.L12:
-	<entry-point>
-	seteq.32    %r33 <- %arg1, $123
-	select.32   %r34 <- %r33, %arg2, $0
-	ret.32      %r34
-
-
-une:
-.L14:
-	<entry-point>
-	setne.32    %r38 <- %arg1, $123
-	select.32   %r39 <- %r38, %arg2, $0
-	ret.32      %r39
-
-
-ubt:
-.L16:
-	<entry-point>
-	setb.32     %r43 <- %arg1, $123
-	select.32   %r44 <- %r43, %arg2, $0
-	ret.32      %r44
-
-
-ube:
-.L18:
-	<entry-point>
-	setbe.32    %r48 <- %arg1, $123
-	select.32   %r49 <- %r48, %arg2, $0
-	ret.32      %r49
-
-
-uae:
-.L20:
-	<entry-point>
-	setae.32    %r53 <- %arg1, $123
-	select.32   %r54 <- %r53, %arg2, $0
-	ret.32      %r54
-
-
-uat:
-.L22:
-	<entry-point>
-	seta.32     %r58 <- %arg1, $123
-	select.32   %r59 <- %r58, %arg2, $0
-	ret.32      %r59
-
-
- * check-output-end
  */
-- 
2.29.2




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux