# HG changeset patch # User lucy # Date 1536590459 -7200 # Node ID 4e99f412148f9f08881b6878e7321288deded5ee # Parent 9d494115eda4a043af84a71a313f55232b7b0dfd 8210319: [s390]: Use of shift operators not covered by cpp standard Reviewed-by: mdoerr, goetz diff -r 9d494115eda4 -r 4e99f412148f src/hotspot/cpu/s390/macroAssembler_s390.cpp --- a/src/hotspot/cpu/s390/macroAssembler_s390.cpp Mon Sep 10 20:17:26 2018 +0800 +++ b/src/hotspot/cpu/s390/macroAssembler_s390.cpp Mon Sep 10 16:40:59 2018 +0200 @@ -465,19 +465,8 @@ z_xihf(r1, -1); } } else { // Distinct src and dst registers. - if (VM_Version::has_DistinctOpnds()) { - load_const_optimized(r1, -1); - z_xgrk(r1, r2, r1); - } else { - if (wide) { - z_lgr(r1, r2); - z_xilf(r1, -1); - z_xihf(r1, -1); - } else { - z_lr(r1, r2); - z_xilf(r1, -1); - } - } + load_const_optimized(r1, -1); + z_xgr(r1, r2); } } @@ -1158,8 +1147,10 @@ // Make sure to keep code size constant -> no value-dependent optimizations. // Do not kill condition code. void MacroAssembler::load_const(Register t, long x) { - Assembler::z_iihf(t, (int)(x >> 32)); - Assembler::z_iilf(t, (int)(x & 0xffffffff)); + // Note: Right shift is only cleanly defined for unsigned types + // or for signed types with nonnegative values. + Assembler::z_iihf(t, (long)((unsigned long)x >> 32)); + Assembler::z_iilf(t, (long)((unsigned long)x & 0xffffffffUL)); } // Load a 32bit constant into a 64bit register, sign-extend or zero-extend. @@ -1256,8 +1247,10 @@ // CPU-version dependend patching of load_const. void MacroAssembler::patch_const(address a, long x) { assert(is_load_const(a), "not a load of a constant"); - set_imm32((address)a, (int) ((x >> 32) & 0xffffffff)); - set_imm32((address)(a + 6), (int)(x & 0xffffffff)); + // Note: Right shift is only cleanly defined for unsigned types + // or for signed types with nonnegative values. + set_imm32((address)a, (long)((unsigned long)x >> 32)); + set_imm32((address)(a + 6), (long)((unsigned long)x & 0xffffffffUL)); } // Patching the value of CPU version dependent load_const_32to64 sequence. @@ -1461,13 +1454,17 @@ // 64 bit value: | part1 | part2 | part3 | part4 | // At least one part is not zero! - int part1 = ((x >> 32) & 0xffff0000) >> 16; - int part2 = (x >> 32) & 0x0000ffff; - int part3 = (x & 0xffff0000) >> 16; - int part4 = (x & 0x0000ffff); + // Note: Right shift is only cleanly defined for unsigned types + // or for signed types with nonnegative values. + int part1 = (int)((unsigned long)x >> 48) & 0x0000ffff; + int part2 = (int)((unsigned long)x >> 32) & 0x0000ffff; + int part3 = (int)((unsigned long)x >> 16) & 0x0000ffff; + int part4 = (int)x & 0x0000ffff; + int part12 = (int)((unsigned long)x >> 32); + int part34 = (int)x; // Lower word only (unsigned). - if ((part1 == 0) && (part2 == 0)) { + if (part12 == 0) { if (part3 == 0) { if (emit) z_llill(t, part4); return 4; @@ -1476,12 +1473,12 @@ if (emit) z_llilh(t, part3); return 4; } - if (emit) z_llilf(t, (int)(x & 0xffffffff)); + if (emit) z_llilf(t, part34); return 6; } // Upper word only. - if ((part3 == 0) && (part4 == 0)) { + if (part34 == 0) { if (part1 == 0) { if (emit) z_llihl(t, part2); return 4; @@ -1490,13 +1487,13 @@ if (emit) z_llihh(t, part1); return 4; } - if (emit) z_llihf(t, (int)(x >> 32)); + if (emit) z_llihf(t, part12); return 6; } // Lower word only (signed). if ((part1 == 0x0000ffff) && (part2 == 0x0000ffff) && ((part3 & 0x00008000) != 0)) { - if (emit) z_lgfi(t, (int)(x & 0xffffffff)); + if (emit) z_lgfi(t, part34); return 6; } @@ -1511,7 +1508,7 @@ len += 4; } } else { - if (emit) z_llihf(t, (int)(x >> 32)); + if (emit) z_llihf(t, part12); len += 6; } @@ -1524,7 +1521,7 @@ len += 4; } } else { - if (emit) z_iilf(t, (int)(x & 0xffffffff)); + if (emit) z_iilf(t, part34); len += 6; } return len;