Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

incorrect optimization where i64 is converted to i192 #12449

Open Quuxplusone opened 12 years ago

Quuxplusone commented 12 years ago
Bugzilla Link PR13042
Status NEW
Importance P enhancement
Reported by Nicholas Matsakis (nmatsakis@mozilla.com)
Reported on 2012-06-06 17:50:28 -0700
Last modified on 2012-06-11 18:10:55 -0700
Version unspecified
Hardware PC All
CC baldrick@free.fr, geek4civic@gmail.com, llvm-bugs@lists.llvm.org, rafael@espindo.la
Fixed by commit(s)
Attachments libsyntax-eat_keyword.bc (2508 bytes, application/octet-stream)
libsyntax-eat_keyword_opt.bc (2224 bytes, application/octet-stream)
libsyntax-eat_keyword.ll (39234 bytes, application/octet-stream)
libsyntax-eat_keyword_opt.ll (36080 bytes, application/octet-stream)
Blocks
Blocked by
See also

Created attachment 8690 bitcode demonstrating the problem

I am attaching a .bc file for a single function. The unoptimized version includes this code:

  %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
  ]

which is compiled into this code:

  %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

It seems to me that the computation of %11 is incorrect. It is masking with 0x10000000000000000ffffffffffffffff but it ought to be masking with 0xffffffffffffffff.

(This is a little endian system)

Quuxplusone commented 12 years ago

Attached libsyntax-eat_keyword.bc (2508 bytes, application/octet-stream): bitcode demonstrating the problem

Quuxplusone commented 12 years ago

to exhibit the problem you must run opt with -O3

Quuxplusone commented 12 years ago

Attached libsyntax-eat_keyword_opt.bc (2224 bytes, application/octet-stream): optimized bitcode

Quuxplusone commented 12 years ago

Attached libsyntax-eat_keyword.ll (39234 bytes, application/octet-stream): unoptimized code in ll form

Quuxplusone commented 12 years ago

Attached libsyntax-eat_keyword_opt.ll (36080 bytes, application/octet-stream): optimize code in ll form