Commit Graph

36 Commits

Author SHA1 Message Date
Hans Kristian Rosbach
bf05e882b8 Continued cleanup of old UNALIGNED_OK checks
- Remove obsolete checks
- Fix checks that are inconsistent
- Stop compiling compare256/longest_match variants that never gets called
- Improve how the generic compare256 functions are handled.
- Allow overriding OPTIMAL_CMP

This simplifies the code and avoids having a lot of code in the compiled library than can never get executed.
2024-12-26 22:14:46 +01:00
Cameron Cawley
d7e121e56b Use GCC's may_alias attribute for unaligned memory access 2024-12-24 12:55:44 +01:00
Hans Kristian Rosbach
509f6b5818 Since we long ago make unaligned reads safe (by using memcpy or intrinsics),
it is time to replace the UNALIGNED_OK checks that have since really only been
used to select the optimal comparison sizes for the arch instead.
2024-12-21 00:46:48 +01:00
Hans Kristian Rosbach
037ab0fd35 Revert "Since we long ago make unaligned reads safe (by using memcpy or intrinsics),"
This reverts commit 80fffd72f3.
It was mistakenly pushed to develop instead of going through a PR and the appropriate reviews.
2024-12-17 23:09:31 +01:00
Hans Kristian Rosbach
80fffd72f3 Since we long ago make unaligned reads safe (by using memcpy or intrinsics),
it is time to replace the UNALIGNED_OK checks that have since really only been
used to select the optimal comparison sizes for the arch instead.
2024-12-17 23:02:32 +01:00
Nathan Moinvaziri
a090529ece Remove deflate_state parameter from update_hash functions. 2024-02-23 13:34:10 +01:00
Nathan Moinvaziri
fc63426372 Update copyright years in other source files. 2024-02-07 19:15:56 +01:00
Hans Kristian Rosbach
dada8e6dc0 Move include files out of match_tpl.h, to simplify dependency handling and
avoid attempting to parse the includes more times than needed.
2024-01-19 16:58:53 +01:00
Nathan Moinvaziri
596f6c2f37 Use memcpy instead of memcmp for unaligned memory comparisons.
Use memcpy because it is better supported for compilers that support unaligned
access than memcmp.
2023-02-08 22:12:37 +01:00
Nathan Moinvaziri
e22195e5bc Don't use unaligned access for memcpy instructions due to GCC 11 assuming it is aligned in certain instances. 2022-08-17 14:41:18 +02:00
Nathan Moinvaziri
ab6665b1be Introduce zmemcmp to use unaligned access for architectures we know support unaligned access, otherwise use memcmp. 2022-02-10 16:10:48 +01:00
Nathan Moinvaziri
363a95fb9b Introduce zmemcpy to use unaligned access for architectures we know support unaligned access, otherwise use memcpy. 2022-02-10 16:10:48 +01:00
Nathan Moinvaziri
87f2ae3f49 Fixed GCC warning about unused variable in longest_match.
match_tpl.h:47:13: warning: unused variable ‘scan_start’ [-Wunused-variable]
   47 |     uint8_t scan_start[8], scan_end[8];
2022-01-25 12:18:22 +01:00
Nathan Moinvaziri
869104562d Clean up and remove bestcmp_t type for longest_match. Use 8 byte buffer (max int comparison size) and cast to integer type when making comparison. 2022-01-17 09:12:53 +01:00
Nathan Moinvaziri
b2ef108051 Remove unused COMPARE258 macro since longest_match only uses COMPARE256. 2022-01-09 21:30:27 +01:00
Nathan Moinvaziri
5bc87f1581 Use memcpy for unaligned reads.
Co-authored-by: Matija Skala <mskala@gmx.com>
2022-01-08 14:33:19 +01:00
Nathan Moinvaziri
e4c622371d Switch longest_match in deflate_slow based on whether or not rolling hash is being used.
Co-authored-by: Hans Kristian Rosbach <hk-git@circlestorm.org>
2021-06-25 20:09:14 +02:00
Hans Kristian Rosbach
8916f295e0 Use UNLIKELY for branches related to rolling hash based on performance profiling.
Co-authored-by: Nathan Moinvaziri <nathan@nathanm.com>
2021-06-25 20:09:14 +02:00
Nathan Moinvaziri
ef416b7e27 Separate fast-zlib matching algorithm into its own longest_match variant. 2021-06-25 20:09:14 +02:00
Nathan Moinvaziri
d87a9f96d0 Incorporate fast-zlib algorithm changes into longest_match. 2021-06-25 20:09:14 +02:00
Hans Kristian Rosbach
cf9127a231 Separate MIN_MATCH into STD_MIN_MATCH and WANT_MIN_MATCH
Rename MAX_MATCH to STD_MAX_MATCH
2021-06-13 20:55:01 +02:00
Nathan Moinvaziri
1617eb163e Store result of early exit trigger at the top of longest_match. 2021-01-28 15:08:26 +01:00
Hans Kristian Rosbach
9326416f0f longest_match optimization 2020-08-31 13:22:54 +02:00
Hans Kristian Rosbach
93ae5483d8 Fix numerous sign-conversion warnings in compare256/compare258 and
longest_match related code.
2020-08-31 13:22:54 +02:00
Hans Kristian Rosbach
de160d6585 Minor comments/whitespace cleanup 2020-08-31 13:22:54 +02:00
Nathan Moinvaziri
7cffba4dd6 Rename ZLIB_INTERNAL to Z_INTERNAL for consistency. 2020-08-31 12:33:16 +02:00
Nathan Moinvaziri
b5a81501f2 Rename ZLIB_REGISTER to Z_REGISTER for consistency. 2020-08-31 12:33:16 +02:00
Hans Kristian Rosbach
e7bb6db09a Replace hash_bits, hash_size and hash_mask with defines. 2020-08-23 09:57:45 +02:00
Nathan Moinvaziri
18ecfceb65 Precalculate match+offset pointer similar to fast-zlib. 2020-08-23 09:56:11 +02:00
Nathan Moinvaziri
8ce4bbfef4 Check for match length exceeding lookahead each time a new best match is found. This reduces some code complexity in GOTO_NEXT_CHAIN by removing the need for RETURN_BEST_LEN. 2020-08-23 09:56:11 +02:00
Nathan Moinvaziri
b0a3461245 Use unaligned 32-bit and 64-bit compare based on best match length when searching for matches.
Move TRIGGER_LEVEL to match_tpl.h since it is only used in longest match.
Use early return inside match loops instead of cont variable.
Added back two variable check for platforms that don't supported unaligned access.
2020-08-23 09:56:11 +02:00
Nathan Moinvaziri
2928d96e2a Fixed possible loss of data warning in LONGEST_MATCH.
match_tpl.h(69,64): warning C4244: '=': conversion from 'unsigned int' to 'Pos', possible loss of data
2020-08-14 22:20:50 +02:00
Nathan Moinvaziri
d5d1f7e81b Fixed extra symbols added to ABI when zlib-compat specified. 2020-08-02 18:32:25 +02:00
Nathan Moinvaziri
e1dbcc186a Added ZLIB_REGISTER to disable register keyword for C++.
Co-authored-by: pps83 <pps83@users.noreply.github.com>
2020-06-28 23:01:17 +02:00
Nathan Moinvaziri
a0fa24f92f Remove IPos typedef which also helps to reduce casting warnings. 2020-05-30 21:29:44 +02:00
Nathan Moinvaziri
7a107a1bc6 Rename match_p.h to match_tpl.h since it has been converted to a template header file. 2020-05-25 15:19:35 +02:00