Skip to content

[GlobalISel][AArch64] Two load instructions generated for single volatile load #35366

@john-brawn-arm

Description

@john-brawn-arm
Bugzilla Link 36018
Resolution FIXED
Resolved on Jan 25, 2018 07:28
Version trunk
OS Linux
Blocks #35152
CC @aemerson,@dsandersllvm,@efriedma-quic,@zmodem,@qcolombet

Extended Description

For the following IR:

@​g = global i16 0, align 2
declare void @​bar(i32)

define hidden void @​foo() {
%1 = load volatile i16, i16* @​g, align 2
%2 = sext i16 %1 to i32
call void @​bar(i32 %2)
ret void
}

llc -mtriple=aarch64 -global-isel generates for the load followed by sext:

adrp x8, g
add x8, x8, :lo12:g
ldrh wzr, [x8]
ldrsh w0, [x8]

g is loaded twice, once with a zero-extending load which is discarded, and second with a sign-extending load. For a volatile load we should be generating only a single load instruction.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions