[llvm] r245851 - [WebAssembly] Implement the is_zero_undef forms of cttz and ctlz
Dan Gohman via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 24 09:39:38 PDT 2015
Author: djg
Date: Mon Aug 24 11:39:37 2015
New Revision: 245851
URL: http://llvm.org/viewvc/llvm-project?rev=245851&view=rev
Log:
[WebAssembly] Implement the is_zero_undef forms of cttz and ctlz
Modified:
llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInteger.td
llvm/trunk/test/CodeGen/WebAssembly/integer32.ll
llvm/trunk/test/CodeGen/WebAssembly/integer64.ll
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInteger.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInteger.td?rev=245851&r1=245850&r2=245851&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInteger.td (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyInstrInteger.td Mon Aug 24 11:39:37 2015
@@ -40,3 +40,9 @@ defm UGE : ComparisonInt<SETUGE>;
defm CLZ : UnaryInt<ctlz>;
defm CTZ : UnaryInt<cttz>;
defm POPCNT : UnaryInt<ctpop>;
+
+// Expand the "don't care" operations to supported operations.
+def : Pat<(ctlz_zero_undef Int32:$src), (CLZ_I32 Int32:$src)>;
+def : Pat<(ctlz_zero_undef Int64:$src), (CLZ_I64 Int64:$src)>;
+def : Pat<(cttz_zero_undef Int32:$src), (CTZ_I32 Int32:$src)>;
+def : Pat<(cttz_zero_undef Int64:$src), (CTZ_I64 Int64:$src)>;
Modified: llvm/trunk/test/CodeGen/WebAssembly/integer32.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/integer32.ll?rev=245851&r1=245850&r2=245851&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/integer32.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/integer32.ll Mon Aug 24 11:39:37 2015
@@ -148,6 +148,15 @@ define i32 @clz32(i32 %x) {
ret i32 %a
}
+; CHECK-LABEL: clz32_zero_undef:
+; CHECK-NEXT: (setlocal @0 (argument 0))
+; CHECK-NEXT: (setlocal @1 (clz @0))
+; CHECK-NEXT: (return @1)
+define i32 @clz32_zero_undef(i32 %x) {
+ %a = call i32 @llvm.ctlz.i32(i32 %x, i1 true)
+ ret i32 %a
+}
+
; CHECK-LABEL: ctz32:
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (ctz @0))
@@ -157,6 +166,15 @@ define i32 @ctz32(i32 %x) {
ret i32 %a
}
+; CHECK-LABEL: ctz32_zero_undef:
+; CHECK-NEXT: (setlocal @0 (argument 0))
+; CHECK-NEXT: (setlocal @1 (ctz @0))
+; CHECK-NEXT: (return @1)
+define i32 @ctz32_zero_undef(i32 %x) {
+ %a = call i32 @llvm.cttz.i32(i32 %x, i1 true)
+ ret i32 %a
+}
+
; CHECK-LABEL: popcnt32:
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (popcnt @0))
Modified: llvm/trunk/test/CodeGen/WebAssembly/integer64.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/integer64.ll?rev=245851&r1=245850&r2=245851&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/integer64.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/integer64.ll Mon Aug 24 11:39:37 2015
@@ -148,6 +148,15 @@ define i64 @clz64(i64 %x) {
ret i64 %a
}
+; CHECK-LABEL: clz64_zero_undef:
+; CHECK-NEXT: (setlocal @0 (argument 0))
+; CHECK-NEXT: (setlocal @1 (clz @0))
+; CHECK-NEXT: (return @1)
+define i64 @clz64_zero_undef(i64 %x) {
+ %a = call i64 @llvm.ctlz.i64(i64 %x, i1 true)
+ ret i64 %a
+}
+
; CHECK-LABEL: ctz64:
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (ctz @0))
@@ -157,6 +166,15 @@ define i64 @ctz64(i64 %x) {
ret i64 %a
}
+; CHECK-LABEL: ctz64_zero_undef:
+; CHECK-NEXT: (setlocal @0 (argument 0))
+; CHECK-NEXT: (setlocal @1 (ctz @0))
+; CHECK-NEXT: (return @1)
+define i64 @ctz64_zero_undef(i64 %x) {
+ %a = call i64 @llvm.cttz.i64(i64 %x, i1 true)
+ ret i64 %a
+}
+
; CHECK-LABEL: popcnt64:
; CHECK-NEXT: (setlocal @0 (argument 0))
; CHECK-NEXT: (setlocal @1 (popcnt @0))
More information about the llvm-commits
mailing list