diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-03-20 15:18:53 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-11-16 20:37:00 +0100 |
| commit | 6e71cf2020fff606a8b57d095d34ffc5bea70d47 (patch) | |
| tree | 61a001587fa1b52a087ce2b33c4d3af1952674a7 /validation/optim | |
| parent | 4750ad6f4d4cb6c44aa86aacfc3a44a7429605fc (diff) | |
| download | sparse-dev-6e71cf2020fff606a8b57d095d34ffc5bea70d47.tar.gz | |
canonicalize compare instructions
Currently only commutative instructions are canonicalized
(the "simpler" operands, often a constant, is forced, if present
to be in the second operand). This improve CSE (more cases are
considered as equivalent) and help to reduce the number of "pattern"
to be handled at simplification.
Do this also for compare instructions since in thsi case we can
swap the order of the operands if at the same time we also swap
the 'direction' on the comparison.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/optim')
| -rw-r--r-- | validation/optim/canonical-cmp.c | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/validation/optim/canonical-cmp.c b/validation/optim/canonical-cmp.c new file mode 100644 index 00000000..19b41631 --- /dev/null +++ b/validation/optim/canonical-cmp.c @@ -0,0 +1,124 @@ +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 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; } + +uint ueq(uint p, uint a) { return (123 == p) ? a : 0; } +uint une(uint p, uint a) { return (123 != p) ? a : 0; } + +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; } + +/* + * check-name: canonical-cmp + * check-command: test-linearize -Wno-decl $file + * + * check-output-exclude: \$123, + * + * check-output-start +seq: +.L0: + <entry-point> + seteq.32 %r4 <- %arg1, $123 + select.32 %r5 <- %r4, %arg2, $0 + ret.32 %r5 + + +sne: +.L2: + <entry-point> + setne.32 %r11 <- %arg1, $123 + select.32 %r12 <- %r11, %arg2, $0 + ret.32 %r12 + + +slt: +.L4: + <entry-point> + setlt.32 %r18 <- %arg1, $123 + select.32 %r19 <- %r18, %arg2, $0 + ret.32 %r19 + + +sle: +.L6: + <entry-point> + setle.32 %r25 <- %arg1, $123 + select.32 %r26 <- %r25, %arg2, $0 + ret.32 %r26 + + +sge: +.L8: + <entry-point> + setge.32 %r32 <- %arg1, $123 + select.32 %r33 <- %r32, %arg2, $0 + ret.32 %r33 + + +sgt: +.L10: + <entry-point> + setgt.32 %r39 <- %arg1, $123 + select.32 %r40 <- %r39, %arg2, $0 + ret.32 %r40 + + +ueq: +.L12: + <entry-point> + seteq.32 %r45 <- %arg1, $123 + select.32 %r46 <- %r45, %arg2, $0 + ret.32 %r46 + + +une: +.L14: + <entry-point> + setne.32 %r50 <- %arg1, $123 + select.32 %r51 <- %r50, %arg2, $0 + ret.32 %r51 + + +ubt: +.L16: + <entry-point> + setb.32 %r55 <- %arg1, $123 + select.32 %r56 <- %r55, %arg2, $0 + ret.32 %r56 + + +ube: +.L18: + <entry-point> + setbe.32 %r60 <- %arg1, $123 + select.32 %r61 <- %r60, %arg2, $0 + ret.32 %r61 + + +uae: +.L20: + <entry-point> + setae.32 %r65 <- %arg1, $123 + select.32 %r66 <- %r65, %arg2, $0 + ret.32 %r66 + + +uat: +.L22: + <entry-point> + seta.32 %r70 <- %arg1, $123 + select.32 %r71 <- %r70, %arg2, $0 + ret.32 %r71 + + + * check-output-end + */ |
