| Index: src/s390/simulator-s390.cc
|
| diff --git a/src/s390/simulator-s390.cc b/src/s390/simulator-s390.cc
|
| index 686a338b274cafc2a76106ebc3c2ae2fba94956a..371a98f91b2322271663475c5597086b308af4d7 100644
|
| --- a/src/s390/simulator-s390.cc
|
| +++ b/src/s390/simulator-s390.cc
|
| @@ -7779,47 +7779,38 @@ EVALUATE(TMLH) {
|
| EVALUATE(TMLL) {
|
| DCHECK_OPCODE(TMLL);
|
| DECODE_RI_A_INSTRUCTION(instr, r1, i2);
|
| - int mask = i2 & 0x0000FFFF;
|
| - if (mask == 0) {
|
| - condition_reg_ = 0x0;
|
| - return length;
|
| - }
|
| + uint32_t mask = i2 & 0x0000FFFF;
|
| uint32_t r1_val = get_low_register<uint32_t>(r1);
|
| r1_val = r1_val & 0x0000FFFF; // uses only the last 16bits
|
|
|
| - // Test if all selected bits are Zero
|
| - bool allSelectedBitsAreZeros = true;
|
| - for (int i = 0; i < 15; i++) {
|
| - if (mask & (1 << i)) {
|
| - if (r1_val & (1 << i)) {
|
| - allSelectedBitsAreZeros = false;
|
| - break;
|
| - }
|
| - }
|
| - }
|
| - if (allSelectedBitsAreZeros) {
|
| + // Test if all selected bits are zeros or mask is zero
|
| + if (0 == (mask & r1_val)) {
|
| condition_reg_ = 0x8;
|
| return length; // Done!
|
| }
|
|
|
| + DCHECK(mask != 0);
|
| // Test if all selected bits are one
|
| - bool allSelectedBitsAreOnes = true;
|
| - for (int i = 0; i < 15; i++) {
|
| - if (mask & (1 << i)) {
|
| - if (!(r1_val & (1 << i))) {
|
| - allSelectedBitsAreOnes = false;
|
| - break;
|
| - }
|
| - }
|
| - }
|
| - if (allSelectedBitsAreOnes) {
|
| + if (mask == (mask & r1_val)) {
|
| condition_reg_ = 0x1;
|
| return length; // Done!
|
| }
|
|
|
| // Now we know selected bits mixed zeros and ones
|
| // Test if the leftmost bit is zero or one
|
| - for (int i = 14; i >= 0; i--) {
|
| +#if defined(__GNUC__)
|
| + int leadingZeros = __builtin_clz(mask);
|
| + mask = 0x80000000u >> leadingZeros;
|
| + if (mask & r1_val) {
|
| + // leftmost bit is one
|
| + condition_reg_ = 0x4;
|
| + } else {
|
| + // leftmost bit is zero
|
| + condition_reg_ = 0x2;
|
| + }
|
| + return length; // Done!
|
| +#else
|
| + for (int i = 15; i >= 0; i--) {
|
| if (mask & (1 << i)) {
|
| if (r1_val & (1 << i)) {
|
| // leftmost bit is one
|
| @@ -7831,6 +7822,8 @@ EVALUATE(TMLL) {
|
| return length; // Done!
|
| }
|
| }
|
| +#endif
|
| + UNREACHABLE();
|
| return length;
|
| }
|
|
|
|
|