diff --git a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index 19322dd6f5b..202ec074e58 100644 --- a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -2784,12 +2784,10 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { return BinaryOperator::CreateAnd(Op0, Builder.CreateNot(X)); // (X & Y) ^ Y --> ~X & Y // (Y & X) ^ Y --> ~X & Y - // Canonical form with a non-splat constant is (X & C) ^ C; don't touch that. - // TODO: Why do we treat arbitrary vector constants differently? + // Canonical form is (X & C) ^ C; don't touch that. // TODO: A 'not' op is better for analysis and codegen, but demanded bits must // be fixed to prefer that (otherwise we get infinite looping). - const APInt *Unused; - if (!match(Op1, m_APInt(Unused)) && + if (!match(Op1, m_Constant()) && match(Op0, m_OneUse(m_c_And(m_Value(X), m_Specific(Op1))))) return BinaryOperator::CreateAnd(Op1, Builder.CreateNot(X)); diff --git a/test/Transforms/InstCombine/zext.ll b/test/Transforms/InstCombine/zext.ll index 887d839cb8c..a53bf6cc028 100644 --- a/test/Transforms/InstCombine/zext.ll +++ b/test/Transforms/InstCombine/zext.ll @@ -35,8 +35,8 @@ define <2 x i64> @test3(<2 x i64> %A) { define <2 x i64> @test4(<2 x i64> %A) { ; CHECK-LABEL: @test4( -; CHECK-NEXT: [[TMP1:%.*]] = xor <2 x i64> %A, -; CHECK-NEXT: [[XOR:%.*]] = and <2 x i64> [[TMP1]], +; CHECK-NEXT: [[AND:%.*]] = and <2 x i64> [[A:%.*]], +; CHECK-NEXT: [[XOR:%.*]] = xor <2 x i64> [[AND]], ; CHECK-NEXT: ret <2 x i64> [[XOR]] ; %trunc = trunc <2 x i64> %A to <2 x i32>