https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91758

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
Ok, so without changed source file I see optimized dump changed from:

  D.1259546.PaddingInReg = SR.6329_147;
  D.1259546.IndirectByVal = SR.6330_121;
  D.1259546.IndirectRealign = SR.6331_117;
  D.1259546.SRetAfterThis = SR.6332_29;
  D.1259546.InReg = SR.6333_124;
  D.1259546.CanBeFlattened = SR.6334_129;
  MEM[base: __for_begin_145, offset: 8B] = MEM[(struct ABIArgInfo
*)&D.1259546];

into:

  _139 = (unsigned char) SR.6329_147;
  _49 = (unsigned char) SR.6330_121;
  _137 = _49 << 2;
  _34 = _137 | _139;
  _382 = (unsigned char) SR.6331_117;
  _381 = _382 << 3;
  _357 = _381 | _34;
  _380 = (unsigned char) SR.6332_29;
  _377 = _380 << 4;
  _376 = _377 | _357;
  _375 = (unsigned char) SR.6333_124;
  _397 = _375 << 5;
  _401 = _397 | _376;
  _181 = (unsigned char) SR.6334_129;
  _364 = _181 << 6;
  _118 = _364 | _401;
  _131 = MEM[(struct ABIArgInfo *)&D.1259546 + 21B];
  _363 = _131 & 130;
  _366 = _118 & 125;
  _69 = _363 | _366;
  MEM[(struct ABIArgInfo *)&D.1259546 + 21B] = _69;
  MEM[base: __for_begin_145, offset: 8B] = MEM[(struct ABIArgInfo
*)&D.1259546];

which eventually ends up with something like:

        addq    $32, %rbx       #, ivtmp.6357
        movzbl  43(%rsp), %ecx  # %sfp, SR.6331
        movq    24(%rsp), %xmm0 # %sfp, tmp336
        movl    %r15d, -8(%rbx) # SR.6327, MEM[base: __for_begin_145, offset:
8B]
        leal    0(,%rdi,4), %edx        #, tmp337
# /tmp/llvm-project/clang/lib/CodeGen/TargetInfo.cpp:7572:      
__builtin_printf ("after: I.info: %d\n", I.info.getInReg ());
        leaq    .LC156(%rip), %rdi      #,
# /tmp/llvm-project/clang/lib/CodeGen/TargetInfo.cpp:7571:       I.info =
classifyArgumentType(I.type, State);
        movl    %r15d, 80(%rsp) # SR.6327, MEM[(struct ABIArgInfo *)&D.1259546
+ 16B]
        sall    $3, %ecx        #, tmp339
        orl     %r14d, %edx     # SR.6329, tmp338
        movhps  8(%rsp), %xmm0  # %sfp, tmp336
        orl     %ecx, %edx      # tmp339, tmp340
        movzbl  42(%rsp), %ecx  # %sfp, tmp341
        movups  %xmm0, -24(%rbx)        # tmp336, MEM[base: __for_begin_145,
offset: 8B]
        movaps  %xmm0, 64(%rsp) # tmp336, MEM[(struct ABIArgInfo *)&D.1259546]
        sall    $4, %ecx        #, tmp341
        orl     %ecx, %edx      # tmp341, tmp342
        orl     %eax, %edx      # tmp343, tmp344
        movl    %ebp, %eax      # SR.6334, tmp345
        sall    $6, %eax        #, tmp345
        orl     %eax, %edx      # tmp345, tmp346
        movzbl  85(%rsp), %eax  # MEM[(struct ABIArgInfo *)&D.1259546 + 21B],
tmp348
        andl    $125, %edx      #, tmp347
        andl    $-126, %eax     #, tmp348
        orl     %eax, %edx      # tmp348, tmp350
# /tmp/llvm-project/clang/lib/CodeGen/TargetInfo.cpp:7572:      
__builtin_printf ("after: I.info: %d\n", I.info.getInReg ());
        xorl    %eax, %eax      #
# /tmp/llvm-project/clang/lib/CodeGen/TargetInfo.cpp:7571:       I.info =
classifyArgumentType(I.type, State);
        movb    %dl, 85(%rsp)   # tmp350, MEM[(struct ABIArgInfo *)&D.1259546 +
21B]

and the problem is that we load:
0x2776490 <(anonymous
namespace)::LanaiABIInfo::computeInfo(clang::CodeGen::CGFunctionInfo&)
const+400> movzbl 0x2b(%rsp),%ecx

with the following value:
(gdb) p /t $ecx
$1 = 11110111

and then we or (11110111 << 3) into %edx and so that we end up with the 6th bit
set.
That is the InReg field.

Looking at the corresponding ASM code without the store-merging, there are
quite some
        andl    $1, %esi        #, tmp329
...
        andl    $1, %ecx        #, tmp347
and so on.

@Eric, @Jakub, @Richard: Aren't we missing something similar with the store
merging of bool:1 bit fields?
I can see the cast to 'unsigned char' from 'bool' in GIMPLE. Both should be 1B
and
so that we maybe encorporate random bits?

Reply via email to