diff options
author | Richard Henderson <rth@twiddle.net> | 2014-07-15 12:07:05 -0700 |
---|---|---|
committer | Richard Henderson <rth@twiddle.net> | 2015-05-21 10:33:36 -0700 |
commit | 8d8d324e3424bf891d41e9c7758dcc09cf3c38b9 (patch) | |
tree | 9b727f276f946e1c531b7849023042b434751796 | |
parent | 57a808b6d7f52a62111f6070933dfca6cd88a0fd (diff) |
target-alpha: Rewrite helper_zapnot
This form produces significantly smaller code on x86_64.
Signed-off-by: Richard Henderson <rth@twiddle.net>
-rw-r--r-- | target-alpha/int_helper.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/target-alpha/int_helper.c b/target-alpha/int_helper.c index 8e4537f5b7..74f38cbe7b 100644 --- a/target-alpha/int_helper.c +++ b/target-alpha/int_helper.c @@ -37,31 +37,25 @@ uint64_t helper_cttz(uint64_t arg) return ctz64(arg); } -static inline uint64_t byte_zap(uint64_t op, uint8_t mskb) +uint64_t helper_zapnot(uint64_t val, uint64_t mskb) { uint64_t mask; - mask = 0; - mask |= ((mskb >> 0) & 1) * 0x00000000000000FFULL; - mask |= ((mskb >> 1) & 1) * 0x000000000000FF00ULL; - mask |= ((mskb >> 2) & 1) * 0x0000000000FF0000ULL; - mask |= ((mskb >> 3) & 1) * 0x00000000FF000000ULL; - mask |= ((mskb >> 4) & 1) * 0x000000FF00000000ULL; - mask |= ((mskb >> 5) & 1) * 0x0000FF0000000000ULL; - mask |= ((mskb >> 6) & 1) * 0x00FF000000000000ULL; - mask |= ((mskb >> 7) & 1) * 0xFF00000000000000ULL; - - return op & ~mask; -} + mask = -(mskb & 0x01) & 0x00000000000000ffull; + mask |= -(mskb & 0x02) & 0x000000000000ff00ull; + mask |= -(mskb & 0x04) & 0x0000000000ff0000ull; + mask |= -(mskb & 0x08) & 0x00000000ff000000ull; + mask |= -(mskb & 0x10) & 0x000000ff00000000ull; + mask |= -(mskb & 0x20) & 0x0000ff0000000000ull; + mask |= -(mskb & 0x40) & 0x00ff000000000000ull; + mask |= -(mskb & 0x80) & 0xff00000000000000ull; -uint64_t helper_zap(uint64_t val, uint64_t mask) -{ - return byte_zap(val, mask); + return val & mask; } -uint64_t helper_zapnot(uint64_t val, uint64_t mask) +uint64_t helper_zap(uint64_t val, uint64_t mask) { - return byte_zap(val, ~mask); + return helper_zapnot(val, ~mask); } uint64_t helper_cmpbge(uint64_t op1, uint64_t op2) |