Skip to content

Instantly share code, notes, and snippets.

@nikomatsakis
Created June 6, 2012 22:13
Show Gist options
  • Save nikomatsakis/2885156 to your computer and use it in GitHub Desktop.
Save nikomatsakis/2885156 to your computer and use it in GitHub Desktop.
# BAD CASE
Unoptimized:
```
%15 = bitcast %"enum parse::token::token[#0]"* %3 to { i64, i8 }*
%16 = getelementptr inbounds { i64, i8 }* %15, i32 0, i32 0
%17 = load i64* %16
switch i64 %17, label %match_else28672 [
i64 35, label %match_case28673
]
```
Optimized:
```
%10 = bitcast i8* addrspace(1)* %9 to i192 addrspace(1)*
%srcval = load i192 addrspace(1)* %10, align 1
%11 = and i192 %srcval, 340282366920938463481821351505477763071
%12 = icmp eq i192 %11, 35
br i1 %12, label %call28676, label %case_body28671
```
What confuses me:
340282366920938463481821351505477763071 is
'10000000000000000ffffffffffffffff'
in hex, which seems to have an extra bit, near as I can tell.
@nikomatsakis
Copy link
Author

what I would expect:

  %10 = bitcast i8* addrspace(1)* %9 to i192 addrspace(1)*
  %srcval = load i192 addrspace(1)* %10, align 1
  %11 = and i192 %srcval, 0xFFFF_FFFF_FFFF_FFFF
  %12 = icmp eq i192 %11, 35
  br i1 %12, label %call28676, label %case_body28671

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment