[llvm-commits] [llvm] r48791 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/xor-undef.ll
Evan Cheng
evan.cheng at apple.com
Tue Mar 25 13:07:13 PDT 2008
Author: evancheng
Date: Tue Mar 25 15:07:13 2008
New Revision: 48791
URL: http://llvm.org/viewvc/llvm-project?rev=48791&view=rev
Log:
Handle a special case xor undef, undef -> 0. Technically this should be transformed to undef. But this is such a common idiom (misuse) we are going to handle it.
Added:
llvm/trunk/test/Transforms/InstCombine/xor-undef.ll
Modified:
llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=48791&r1=48790&r2=48791&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue Mar 25 15:07:13 2008
@@ -4425,8 +4425,13 @@
bool Changed = SimplifyCommutative(I);
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
- if (isa<UndefValue>(Op1))
+ if (isa<UndefValue>(Op1)) {
+ if (isa<UndefValue>(Op0))
+ // Handle undef ^ undef -> 0 special case. This is a common
+ // idiom (misuse).
+ return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
return ReplaceInstUsesWith(I, Op1); // X ^ undef -> undef
+ }
// xor X, X = 0, even if X is nested in a sequence of Xor's.
if (Instruction *Result = AssociativeOpt(I, XorSelf(Op1))) {
Added: llvm/trunk/test/Transforms/InstCombine/xor-undef.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/xor-undef.ll?rev=48791&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/xor-undef.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/xor-undef.ll Tue Mar 25 15:07:13 2008
@@ -0,0 +1,6 @@
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep zeroinitializer
+
+define <2 x i64> @f() {
+ %tmp = xor <2 x i64> undef, undef
+ ret <2 x i64> %tmp
+}
More information about the llvm-commits
mailing list