Skip to content

[11->12 regression] Improper assignment fusion #49979

@llvmbot

Description

@llvmbot
Bugzilla Link 50635
Resolution DUPLICATE
Resolved on Jun 09, 2021 11:13
Version unspecified
OS Linux
Blocks #48661
Reporter LLVM Bugzilla Contributor
CC @jyknight,@RKSimon,@tstellar

Extended Description

To reproduce:

#include <stdint.h>

struct S1 {
uint8_t val1;
uint8_t this_gets_clobbered;
uint16_t val2;
};

void test(S1 src, S1* dest) {
dest->val1 = src.val1;
dest->val2 = src.val2;
}

Compile with -O1 or higher, with Clang 12.0.0 or higher (codegen is proper on 11.0.1).

Expected result:

test(S1, S1*): # @​test(S1, S1*)
mov byte ptr [rsi], dil
shr edi, 16
mov word ptr [rsi + 2], di
ret

Actual result:

test(S1, S1*): # @​test(S1, S1*)
mov dword ptr [rsi], edi
ret

Compiler Explorer: https://godbolt.org/z/1W1oKdfcG

Found by user @​fifty#1323 on Discord.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzilladuplicateResolved as duplicate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions