[llvm] r298201 - [Analysis] bitreverse(undef) returns undef
Brian Gesiak via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 18 21:40:43 PDT 2017
Author: modocache
Date: Sat Mar 18 23:40:42 2017
New Revision: 298201
URL: http://llvm.org/viewvc/llvm-project?rev=298201&view=rev
Log:
[Analysis] bitreverse(undef) returns undef
Summary:
The reverse of an artbitrary bitpattern is also an arbitrary
bitpattern.
Reviewers: trentxintong, arsenm, majnemer
Reviewed By: majnemer
Subscribers: majnemer, wdng, llvm-commits
Differential Revision: https://reviews.llvm.org/D31118
Modified:
llvm/trunk/lib/Analysis/ConstantFolding.cpp
llvm/trunk/test/Transforms/InstCombine/bitreverse-fold.ll
Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=298201&r1=298200&r2=298201&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Sat Mar 18 23:40:42 2017
@@ -1768,7 +1768,8 @@ Constant *ConstantFoldScalarCall(StringR
}
if (isa<UndefValue>(Operands[0])) {
- if (IntrinsicID == Intrinsic::bswap)
+ if (IntrinsicID == Intrinsic::bswap ||
+ IntrinsicID == Intrinsic::bitreverse)
return Operands[0];
return nullptr;
}
Modified: llvm/trunk/test/Transforms/InstCombine/bitreverse-fold.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/bitreverse-fold.ll?rev=298201&r1=298200&r2=298201&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/bitreverse-fold.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/bitreverse-fold.ll Sat Mar 18 23:40:42 2017
@@ -37,6 +37,13 @@ define i32 @reverse_neg1_i32() {
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 @@ define i1 @reverse_true_i1() {
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() {
More information about the llvm-commits
mailing list