[llvm-bugs] [Bug 49357] New: [AArch64/FastIsel] Misoptimization of sext from function argument in the presence of spills.
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Feb 25 12:50:06 PST 2021
https://bugs.llvm.org/show_bug.cgi?id=49357
Bug ID: 49357
Summary: [AArch64/FastIsel] Misoptimization of sext from
function argument in the presence of spills.
Product: libraries
Version: trunk
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: AArch64
Assignee: unassignedbugs at nondot.org
Reporter: keno at alumni.harvard.edu
CC: arnaud.degrandmaison at arm.com,
llvm-bugs at lists.llvm.org, smithp352 at googlemail.com,
Ties.Stuij at arm.com
Created attachment 24573
--> https://bugs.llvm.org/attachment.cgi?id=24573&action=edit
Testcase showing the issue.
Consider the attached testcase.ll, reduced from a downstream issue report at
https://github.com/JuliaLang/julia/issues/39823.
The relevant snippet of the testcase is:
```
define nonnull {}* @julia_f_1854(i32 signext %0) #0 {
[snip]
call void inttoptr (i64 4342098656 to void ()*)()
[snip]
%10 = sext i32 %0 to i64
%11 = icmp slt i64 %10, 0
```
When run as `llc -mtriple arm64-apple-darwin20.0.0 -mcpu apple-a12
-code-model=small -O0 -fast-isel -o - testcase.ll`, the produced assembly is in
relevant part:
```
str w0, [sp, #8] ; 4-byte Folded Spill
blr x8
ldr w9, [sp, #8] ; 4-byte Folded Reload
[snip]
mov x8, x9
cmp x8, #0
```
Note that the sext got isel'ed to a `mov x8, x9`. This is because of
fast isel decided at [1] that this sext did not need an actual instruction
because of the arguments signext attribute. However, the implementation does
not work, because upper bits of the SUBREG_TO_REG'd register are undefined and
subsequent passes may clobber them (e.g. as in this case by a stack spill).
[1]
https://github.com/llvm/llvm-project/blob/2c56776a319edf33505ca6c7f9be59657cdaf52b/llvm/lib/Target/AArch64/AArch64FastISel.cpp#L4598-L4618
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210225/54b3f7b3/attachment.html>
More information about the llvm-bugs
mailing list