[LLVMbugs] [Bug 8730] New: Missed optimization in passing bools
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Dec 2 16:43:50 PST 2010
http://llvm.org/bugs/show_bug.cgi?id=8730
Summary: Missed optimization in passing bools
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: LLVM Codegen
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: jyasskin at google.com
CC: nicholas at mxc.ca, llvmbugs at cs.uiuc.edu
$ cat missed_opt.cc
void called(bool b);
void wrapper(bool* b) {
called(*b);
}
$ g++ --version
g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3
$ g++ -S -O2 missed_opt.cc -o -
...
_Z7wrapperPb:
.LFB0:
.cfi_startproc
.cfi_personality 0x3,__gxx_personality_v0
movzbl (%rdi), %edi
jmp _Z6calledb
...
$ clang++ -S -O2 missed_opt.cc -o -
...
_Z7wrapperPb: # @_Z7wrapperPb
.Leh_func_begin0:
# BB#0: # %entry
pushq %rbp
.Ltmp0:
movq %rsp, %rbp
.Ltmp1:
movb (%rdi), %al
andb $1, %al
movzbl %al, %edi
popq %rbp
jmp _Z6calledb # TAILCALL
$ clang++ -S -emit-llvm -O2 missed_opt.cc -o -
target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-unknown-linux-gnu"
define void @_Z7wrapperPb(i8* nocapture %b) {
entry:
%tmp1 = load i8* %b, align 1, !tbaa !0
%tmp = and i8 %tmp1, 1
%tobool = icmp ne i8 %tmp, 0
tail call void @_Z6calledb(i1 zeroext %tobool)
ret void
}
declare void @_Z6calledb(i1 zeroext)
$
The extra 'and' instruction seems to show up any time a bool is loaded from
memory. Nick suggests fixing it by bitcasting to i1* before doing the load.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list