From: H.J. Lu Date: Tue, 17 Feb 2026 05:45:09 +0000 (+0800) Subject: x86: Don't mark clobbered FLAGS_REG as live X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58b6004e920a0ddee5726b98e272405d112a8ec2;p=thirdparty%2Fgcc.git x86: Don't mark clobbered FLAGS_REG as live Don't mark clobbered FLAGS_REG as live in (parallel [(set (reg:SI 119) (lshiftrt:SI (reg:SI 121) (const_int 16 [0x10]))) (clobber (reg:CC 17 flags))]) gcc/ PR target/124136 * config/i386/i386-features.cc (ix86_check_flags_reg): Don't mark clobbered FLAGS_REG as live. gcc/testsuite/ PR target/124136 * g++.target/i386/pr124136.C: New file. Signed-off-by: H.J. Lu --- diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc index d5435f009cb..4e94b2f742e 100644 --- a/gcc/config/i386/i386-features.cc +++ b/gcc/config/i386/i386-features.cc @@ -3903,8 +3903,11 @@ ix86_get_dominator_for_reg (unsigned int regno, basic_block bb) registers, if DEST is FLAGS register. */ static void -ix86_check_flags_reg (rtx dest, const_rtx, void *data) +ix86_check_flags_reg (rtx dest, const_rtx x, void *data) { + if (GET_CODE (x) == CLOBBER) + return; + auto_bitmap *live_caller_saved_regs = (auto_bitmap *) data; if (REG_P (dest) && REGNO (dest) == FLAGS_REG) bitmap_set_bit (*live_caller_saved_regs, FLAGS_REG); diff --git a/gcc/testsuite/g++.target/i386/pr124136.C b/gcc/testsuite/g++.target/i386/pr124136.C new file mode 100644 index 00000000000..331ff46bb66 --- /dev/null +++ b/gcc/testsuite/g++.target/i386/pr124136.C @@ -0,0 +1,29 @@ +/* { dg-do compile { target *-*-linux* } } */ +/* { dg-options "-O1 -fPIC -fvisibility=internal -mtls-dialect=gnu" } */ + +__thread int err; +bool m; +struct Operand { + int : 6; + int kind_ : 10; + int bit_ : 4; + Operand(){}; +}; +struct Reg32e : Operand {}; +Operand mm; +void f1(); +void f(Reg32e B) { + for (;;) + { + Operand &r = B; + m = r.kind_ && r.bit_ & 1; + if (err) + err = 1; + int t = r.bit_; + if (t) + mm = r; + f1(); + } +} + +/* { dg-final { scan-assembler-times "call\[ \t\]__tls_get_addr@PLT" 1 { target { ! ia32 } } } } */