[llvm-bugs] [Bug 42285] New: If-conversion fails to remove CPSR operand on thumb instructions, causing incorrect assembly
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Jun 14 06:28:47 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=42285
Bug ID: 42285
Summary: If-conversion fails to remove CPSR operand on thumb
instructions, causing incorrect assembly
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Backend: ARM
Assignee: unassignedbugs at nondot.org
Reporter: john.brawn at arm.com
CC: llvm-bugs at lists.llvm.org, peter.smith at linaro.org,
Ties.Stuij at arm.com
If you compile the following:
int a, b;
int c() { return b <= 0 && a && b && 7 / b ? b : b * a; }
with clang --target=arm-none-eabi -march=armv8-a -S -Os -mthumb then in the
assembly output you see
it eq
mulseq r0, r1, r0
This mulseq is invalid, and if you try to assemble it you get an invalid
instruction error. If you generate an object file directly though you get
it eq
muleq r0, r1, r0
which is correct.
What's going on here is that the 16-bit mul instruction is flags-setting
outside of an IT block, and non-flags-setting inside of it. This is modelled in
LLVM using an optional CPSR operand: if the operand is present then it's
flags-setting, if it's not then it's not. The CPSR operand is initially present
but marked as dead, then when deciding whether to predicate it
ARMBaseInstrInfo::isPredicable asks isEligibleForITBlock which asks
ARMBaseInstrInfo::isCPSRDefined which says CPSR is not defined as it's dead.
The logic deciding that it is safe to predicate the mul looks correct here, so
we just need to remove the dead CPSR operand. Looks like either
ARMBaseInstrInfo::PredicateInstruction or possibly
Thumb2ITBlockPass::InsertITInstructions would be the place to do this.
--
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/20190614/87daa399/attachment-0001.html>
More information about the llvm-bugs
mailing list