[PATCH] D88823: [CodeGen][TailDuplicator] Don't duplicate blocks with INLINEASM_BR
Bill Wendling via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 5 23:50:20 PDT 2020
void added a comment.
One thing, I believe we're trying to turn "asm goto" into something it was never meant to be. If you look at gcc's output for this code:
int foo(int a, int b) {
int x;
if (a < 42) {
x = 0;
asm goto("# 1\n\t.data %l1" : : "r"(b) : : indirect);
}
if (b > 42) {
x = 37;
asm goto("# 2\n\t.data %l1" : : "r"(a) : : indirect);
}
indirect:
x = a + b - x;
ret:
return x;
}
GCC doesn't combine the indirect destination:
.file "asm-goto-phi.c"
.text
.p2align 4
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
movl %esi, %eax
cmpl $41, %edi
jg .L2
#APP
# 6 "asm-goto-phi.c" 1
# 1
.data .L5
# 0 "" 2
#NO_APP
.L2:
xorl %edx, %edx
cmpl $42, %eax
jle .L3
#APP
# 10 "asm-goto-phi.c" 1
# 2
.data .L4
# 0 "" 2
#NO_APP
.L4:
movl $37, %edx
.L3:
addl %edi, %eax
subl %edx, %eax
ret
.p2align 4,,10
.p2align 3
.L5:
xorl %edx, %edx
addl %edi, %eax
subl %edx, %eax
ret
.cfi_endproc
.LFE0:
.size foo, .-foo
.ident "GCC: (Debian 9.3.0-14) 9.3.0"
.section .note.GNU-stack,"", at progbits
This side steps the issue of resolving PHI nodes.
But whatever. You guys come up with something.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88823/new/
https://reviews.llvm.org/D88823
More information about the llvm-commits
mailing list