[llvm-dev] Bug on llvm backend (llc) when the integer type is not power of 2?

Fangqing Du via llvm-dev llvm-dev at lists.llvm.org
Tue Mar 9 19:22:24 PST 2021


Hi all,

When I run cmd '*llc -mtriple=x86_64-linux -filetype=obj tmp.ll -o tmp.o*'
and '*g++ tmp.o -o exe*' on following llvm-ir, I'll get wrong output.
Here '%r' and '%zt' should be 0x3FFFD, but output is 0xFFFFFD.

Is this a bug?
If it's a bug, then how can I workaround this? (Any llc option can avoid
this?)

Thanks a lot!
Fangqing
Xilinx Inc.

; ModuleID = 'main7.bc'

source_filename = "main.cpp"

target datalayout =
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"

target triple = "x86_64-unknown-linux-gnu"


@.str = private unnamed_addr constant [9 x i8] c"adu: %d\0A\00", align 1


; Function Attrs: noinline norecurse optnone uwtable

define i32 @main() #0 {

entry:

  %a = alloca i24, align 4

  store i24 -3, i24* %a, align 4; 0xFFFFFD

  %bc = bitcast i24* %a to i18*

  %r = load i18, i18* %bc, align 4

  %zt = zext i18 %r to i40; should be 0x3FFFD

  ;%or = or i40 %zt, 267386880

  %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8],
[9 x i8]* @.str, i32 0, i32 0), i18 %r)

  %call2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8],
[9 x i8]* @.str, i32 0, i32 0), i40 %zt)

  ;%call3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x
i8], [9 x i8]* @.str, i32 0, i32 0), i40 %or)

  ret i32 0

}


declare i32 @printf(i8*, ...) #1


attributes #0 = { noinline norecurse optnone uwtable
"correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false"
"frame-pointer"="all" "less-precise-fpmad"="false" "no-infs-fp-math"="false"
"no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"
="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8"
"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87"
"unsafe-fp-math"="false" "use-soft-float"="false" }

attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false"
"disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"=
"false" "no-infs-fp-math"="false" "no-nans-fp-math"="false"
"no-signed-zeros-fp-math"="false" "no-trapping-math"="false"
"stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"=
"+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"=
"false" }


!llvm.module.flags = !{!0}

!llvm.ident = !{!1}


!0 = !{i32 1, !"wchar_size", i32 4}

!1 = !{!"clang version 7.0.0 "}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210309/4e6ba43d/attachment.html>


More information about the llvm-dev mailing list