[PATCH] D36439: [InstCombine] Simplify and merge FoldOrWithConstants/FoldXorWithConstants

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 13 10:53:46 PDT 2017

spatel added inline comments.

Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1832
-  Value *V1 = nullptr;
-  ConstantInt *CI2 = nullptr;
-  if (!match(Op, m_And(m_Value(V1), m_ConstantInt(CI2)))) return nullptr;
+  ConstantInt *CI2 = dyn_cast<ConstantInt>(C2);
Dropped the null check on CI2? This will crash:

define i32 @D36439(i32 %a, i32 %b, i32 %c) {
  %tmp = or i32 %b, %a
  %tmp1 = and i32 %tmp, 1
  %tmp2 = and i32 %b, %c
  %tmp3 = or i32 %tmp1, %tmp2
  ret i32 %tmp3



More information about the llvm-commits mailing list