i65 is super weird
This commit is contained in:
parent
0ddb1f8dc5
commit
a8d4c65179
|
@ -2,9 +2,9 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
uint64_t i = (uint64_t)(-1LL);
|
uint64_t i = 1UL << 63;
|
||||||
uint64_t j = (uint64_t)(-1LL);
|
uint64_t j = 1UL << 63;
|
||||||
uint64_t k = i + j;
|
uint64_t k = (i + j) >> 1;
|
||||||
printf("%lu + %lu = %lu\n", i, j, k);
|
printf("(%lu + %lu) >> 1 = %lu\n", i, j, k);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ source_filename = "i65.c"
|
||||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||||
target triple = "x86_64-pc-linux-gnu"
|
target triple = "x86_64-pc-linux-gnu"
|
||||||
|
|
||||||
@.str = private unnamed_addr constant [17 x i8] c"%lu + %lu = %lu\0A\00", align 1
|
@.str = private unnamed_addr constant [24 x i8] c"(%lu + %lu) >> 1 = %lu\0A\00", align 1
|
||||||
|
|
||||||
; Function Attrs: noinline nounwind optnone sspstrong uwtable
|
; Function Attrs: noinline nounwind optnone sspstrong uwtable
|
||||||
define dso_local i32 @main(i32, i8**) #0 {
|
define dso_local i32 @main(i32, i8**) #0 {
|
||||||
|
@ -16,19 +16,20 @@ define dso_local i32 @main(i32, i8**) #0 {
|
||||||
store i32 0, i32* %3, align 4
|
store i32 0, i32* %3, align 4
|
||||||
store i32 %0, i32* %4, align 4
|
store i32 %0, i32* %4, align 4
|
||||||
store i8** %1, i8*** %5, align 8
|
store i8** %1, i8*** %5, align 8
|
||||||
store i65 -1, i65* %6, align 8
|
store i65 -9223372036854775808, i65* %6, align 8
|
||||||
store i65 -1, i65* %7, align 8
|
store i65 -9223372036854775808, i65* %7, align 8
|
||||||
%9 = load i65, i65* %6, align 8
|
%9 = load i65, i65* %6, align 8
|
||||||
%10 = load i65, i65* %7, align 8
|
%10 = load i65, i65* %7, align 8
|
||||||
%11 = add i65 %9, %10
|
%11 = add i65 %9, %10
|
||||||
store i65 %11, i65* %8, align 8
|
%12 = lshr i65 %11, 1
|
||||||
%12 = load i65, i65* %6, align 8
|
store i65 %12, i65* %8, align 8
|
||||||
%13 = load i65, i65* %7, align 8
|
%13 = load i65, i65* %6, align 8
|
||||||
%14 = load i65, i65* %8, align 8
|
%14 = load i65, i65* %7, align 8
|
||||||
%15 = trunc i65 %12 to i64
|
%15 = load i65, i65* %8, align 8
|
||||||
%16 = trunc i65 %13 to i64
|
%16 = trunc i65 %13 to i64
|
||||||
%17 = trunc i65 %14 to i64
|
%17 = trunc i65 %14 to i64
|
||||||
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i32 0, i32 0), i64 %15, i64 %16, i64 %17)
|
%18 = trunc i65 %15 to i64
|
||||||
|
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i32 0, i32 0), i64 %16, i64 %17, i64 %18)
|
||||||
ret i32 0
|
ret i32 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,35 +12,32 @@ main: # @main
|
||||||
.cfi_offset rbp, -16
|
.cfi_offset rbp, -16
|
||||||
mov rbp, rsp
|
mov rbp, rsp
|
||||||
.cfi_def_cfa_register rbp
|
.cfi_def_cfa_register rbp
|
||||||
sub rsp, 80
|
sub rsp, 64
|
||||||
mov dword ptr [rbp - 56], 0
|
mov dword ptr [rbp - 40], 0
|
||||||
mov dword ptr [rbp - 52], edi
|
mov dword ptr [rbp - 36], edi
|
||||||
mov qword ptr [rbp - 64], rsi
|
mov qword ptr [rbp - 64], rsi
|
||||||
|
movabs rax, -9223372036854775808
|
||||||
|
mov qword ptr [rbp - 32], rax
|
||||||
mov byte ptr [rbp - 24], 1
|
mov byte ptr [rbp - 24], 1
|
||||||
mov qword ptr [rbp - 32], -1
|
mov qword ptr [rbp - 16], rax
|
||||||
mov byte ptr [rbp - 8], 1
|
mov byte ptr [rbp - 8], 1
|
||||||
mov qword ptr [rbp - 16], -1
|
|
||||||
movzx eax, byte ptr [rbp - 24]
|
movzx eax, byte ptr [rbp - 24]
|
||||||
mov rcx, qword ptr [rbp - 32]
|
mov rcx, qword ptr [rbp - 32]
|
||||||
movzx edx, byte ptr [rbp - 8]
|
movzx edx, byte ptr [rbp - 8]
|
||||||
mov rsi, qword ptr [rbp - 16]
|
mov rsi, qword ptr [rbp - 16]
|
||||||
add rcx, rsi
|
add rcx, rsi
|
||||||
adc rax, rdx
|
adc rax, rdx
|
||||||
mov qword ptr [rbp - 48], rcx
|
shld rax, rcx, 63
|
||||||
and eax, 1
|
mov qword ptr [rbp - 56], rax
|
||||||
mov byte ptr [rbp - 40], al
|
mov byte ptr [rbp - 48], 0
|
||||||
movzx edx, byte ptr [rbp - 24]
|
|
||||||
mov rsi, qword ptr [rbp - 32]
|
mov rsi, qword ptr [rbp - 32]
|
||||||
movzx r8d, byte ptr [rbp - 8]
|
mov rdx, qword ptr [rbp - 16]
|
||||||
mov rcx, qword ptr [rbp - 16]
|
mov rcx, qword ptr [rbp - 56]
|
||||||
movzx eax, byte ptr [rbp - 40]
|
movabs rdi, offset .L.str
|
||||||
mov r9, qword ptr [rbp - 48]
|
mov al, 0
|
||||||
mov qword ptr [rsp], rax
|
|
||||||
mov edi, offset .L.str
|
|
||||||
xor eax, eax
|
|
||||||
call printf
|
call printf
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
add rsp, 80
|
add rsp, 64
|
||||||
pop rbp
|
pop rbp
|
||||||
.cfi_def_cfa rsp, 8
|
.cfi_def_cfa rsp, 8
|
||||||
ret
|
ret
|
||||||
|
@ -51,8 +48,8 @@ main: # @main
|
||||||
.type .L.str,@object # @.str
|
.type .L.str,@object # @.str
|
||||||
.section .rodata.str1.1,"aMS",@progbits,1
|
.section .rodata.str1.1,"aMS",@progbits,1
|
||||||
.L.str:
|
.L.str:
|
||||||
.asciz "%lu + %lu = %lu\n"
|
.asciz "(%lu + %lu) >> 1 = %lu\n"
|
||||||
.size .L.str, 17
|
.size .L.str, 24
|
||||||
|
|
||||||
|
|
||||||
.ident "clang version 7.0.0 (tags/RELEASE_700/final)"
|
.ident "clang version 7.0.0 (tags/RELEASE_700/final)"
|
||||||
|
|
Loading…
Reference in a new issue