[llvm-commits] [llvm] r96432 - in /llvm/trunk: lib/Analysis/ConstantFolding.cpp test/Transforms/InstCombine/bswap-fold.ll
Dan Gohman
gohman at apple.com
Tue Feb 16 16:54:58 PST 2010
Author: djg
Date: Tue Feb 16 18:54:58 2010
New Revision: 96432
URL: http://llvm.org/viewvc/llvm-project?rev=96432&view=rev
Log:
Fold bswap(undef) to undef.
Modified:
llvm/trunk/lib/Analysis/ConstantFolding.cpp
llvm/trunk/test/Transforms/InstCombine/bswap-fold.ll
Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=96432&r1=96431&r2=96432&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Tue Feb 16 18:54:58 2010
@@ -1179,6 +1179,12 @@
return 0;
}
+ if (isa<UndefValue>(Operands[0])) {
+ if (Name.startswith("llvm.bswap"))
+ return Operands[0];
+ return 0;
+ }
+
return 0;
}
Modified: llvm/trunk/test/Transforms/InstCombine/bswap-fold.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/bswap-fold.ll?rev=96432&r1=96431&r2=96432&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/bswap-fold.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/bswap-fold.ll Tue Feb 16 18:54:58 2010
@@ -67,3 +67,9 @@
%D = tail call i16 @llvm.bswap.i16(i16 %C) nounwind
ret i16 %D
}
+
+; Misc: Fold bswap(undef) to undef.
+define i64 @foo() {
+ %a = call i64 @llvm.bswap.i64(i64 undef)
+ ret i64 %a
+}
More information about the llvm-commits
mailing list