diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 52ee2c49a6244a4cb93e5e45c87347b2d975781b..01c698257bb965e0ece9d1aff25843735f4c602c 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -2546,7 +2546,10 @@ (clobber (reg:CC FLAGS_REG))])] { int shift = ctz_hwi (UINTVAL (operands[1])); - operands[1] = gen_int_mode (UINTVAL (operands[1]) >> shift, DImode); + rtx op1 = gen_int_mode (UINTVAL (operands[1]) >> shift, DImode); + if (ix86_endbr_immediate_operand (op1, VOIDmode)) + FAIL; + operands[1] = op1; operands[2] = gen_int_mode (shift, QImode); }) diff --git a/gcc/testsuite/gcc.dg/pr112845.c b/gcc/testsuite/gcc.dg/pr112845.c new file mode 100644 index 0000000000000000000000000000000000000000..ece6f451e7580e6d2f45fe88493ddaeeb9e2434d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr112845.c @@ -0,0 +1,9 @@ +/* PR target/112845 */ +/* { dg-do compile { target cet } } */ +/* { dg-options "-Os -fcf-protection" } */ + +unsigned long long +foo (void) +{ + return 0xfa1e0ff3ULL << 3; +}