[WebAssembly] Add avgr_u intrinsics and require nuw in patterns
authorThomas Lively <tlively@google.com>
Wed, 18 Dec 2019 05:53:46 +0000 (21:53 -0800)
committerThomas Lively <tlively@google.com>
Wed, 18 Dec 2019 23:31:38 +0000 (15:31 -0800)
commit71eb8023d85e5201d32ea24194ec5bc07db23527
tree3acd353f10f51715b5e5419212d729c8ad5d9244
parent6218696bc938ce108da9ddb7b13cb187d0413e86
[WebAssembly] Add avgr_u intrinsics and require nuw in patterns

Summary:
The vector pattern `(a + b + 1) / 2` was previously selected to an
avgr_u instruction regardless of nuw flags, but this is incorrect in
the case where either addition may have an unsigned wrap. This CL
changes the existing pattern to require both adds to have nuw flags
and adds builtin functions and intrinsics for the avgr_u instructions
because the corrected pattern is not representable in C.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D71648
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-wasm.c
llvm/include/llvm/IR/IntrinsicsWebAssembly.td
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/CodeGen/WebAssembly/simd-arith.ll
llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll