[PATCH] D31118: [Analysis] bitreverse(undef) returns undef
Brian Gesiak via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 18 19:46:36 PDT 2017
modocache created this revision.
Herald added a subscriber: wdng.
The reverse of an artbitrary bitpattern is also an arbitrary
bitpattern.
https://reviews.llvm.org/D31118
Files:
lib/Analysis/ConstantFolding.cpp
test/Transforms/InstCombine/bitreverse-fold.ll
Index: test/Transforms/InstCombine/bitreverse-fold.ll
===================================================================
--- test/Transforms/InstCombine/bitreverse-fold.ll
+++ test/Transforms/InstCombine/bitreverse-fold.ll
@@ -37,6 +37,13 @@
ret i32 %x
}
+; CHECK-LABEL: @reverse_undef_i32(
+; CHECK-NEXT: ret i32 undef
+define i32 @reverse_undef_i32() {
+ %x = call i32 @llvm.bitreverse.i32(i32 undef)
+ ret i32 %x
+}
+
; CHECK-LABEL: @reverse_false_i1(
; CHECK-NEXT: ret i1 false
define i1 @reverse_false_i1() {
@@ -51,6 +58,13 @@
ret i1 %x
}
+; CHECK-LABEL: @reverse_undef_i1(
+; CHECK-NEXT: ret i1 undef
+define i1 @reverse_undef_i1() {
+ %x = call i1 @llvm.bitreverse.i1(i1 undef)
+ ret i1 %x
+}
+
; CHECK-LABEL: @reverse_false_v2i1(
; CHECK-NEXT: ret <2 x i1> zeroinitializer
define <2 x i1> @reverse_false_v2i1() {
Index: lib/Analysis/ConstantFolding.cpp
===================================================================
--- lib/Analysis/ConstantFolding.cpp
+++ lib/Analysis/ConstantFolding.cpp
@@ -1768,7 +1768,8 @@
}
if (isa<UndefValue>(Operands[0])) {
- if (IntrinsicID == Intrinsic::bswap)
+ if (IntrinsicID == Intrinsic::bswap ||
+ IntrinsicID == Intrinsic::bitreverse)
return Operands[0];
return nullptr;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31118.92258.patch
Type: text/x-patch
Size: 1297 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170319/475a5b74/attachment.bin>
More information about the llvm-commits
mailing list