[LLVMdev] Unnecessary i16 -> i32 type promotion
Marc de Kruijf
dekruijf at cs.wisc.edu
Sun Jul 19 13:42:09 PDT 2009
If I have an '&' operator inside an 'if' statement, LLVM seems to always
promote a 16 bit integer type to a 32 bit integer type. I don't want this
to happen because my back-end only supports 16 bit types. Why is this
happening? Where might this be happening, so I can fix it? It doesn't seem
to happen with the '|' operator, only '&'. Thanks!
Code is below. Relevant code highlighted in *bold*.
C Function:
-------------------
$cat test.c
short foo(short a) {
if *(a & 1)*
return -1;
else
return 1;
}
LLVM:
---------------------
$ cat test.ll
; ModuleID = 'test.o'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
target triple = "i386-pc-linux-gnu"
define signext i16 @foo(i16 signext %a) nounwind readnone {
entry:
*%0 = zext i16 %a to i32 ; <i32> [#uses=1]*
%1 = and i32 %0, 1 ; <i32> [#uses=1]
%toBool = icmp eq i32 %1, 0 ; <i1> [#uses=1]
%.0 = select i1 %toBool, i16 1, i16 -1 ; <i16> [#uses=1]
ret i16 %.0
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090719/1c7e7ec9/attachment.html>
More information about the llvm-dev
mailing list