[llvm-dev] wasm: Bad codegen for i8 comparison

Carlo Kok via llvm-dev llvm-dev at lists.llvm.org
Thu Jan 11 00:51:35 PST 2018


(Currently using a build from november but I didn't see any commit that 
could fix this for wasm); With the wasm backend,


  %2 = icmp sgt i8 %0, -1

becomes:
         i32.const       $4=, 255
         i32.const       $2=, 255
         i32.and         $3=, $0, $2
         i32.const       $5=, 255
         i32.and         $6=, $4, $5
         i32.gt_s        $7=, $3, $6

Which essentially does (arg & 0xff) > (0xff & 0xff) (if I read it 
correctly) and seems to always result in false.

Full testcase:
https://gist.github.com/carlokok/579b7793465cd0299cf4c609c569f559


More information about the llvm-dev mailing list