diff options
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | 4 | ||||
| -rw-r--r-- | llvm/test/Transforms/InstCombine/pr32686.ll | 22 |
2 files changed, 24 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index b2a41c69920..2906d34ee3d 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -2078,7 +2078,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { Value *NOr = Builder->CreateOr(A, Op1); NOr->takeName(Op0); return BinaryOperator::CreateXor(NOr, - cast<Instruction>(Op0)->getOperand(1)); + ConstantInt::get(NOr->getType(), *C)); } // Y|(X^C) -> (X|Y)^C iff Y&C == 0 @@ -2087,7 +2087,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { Value *NOr = Builder->CreateOr(A, Op0); NOr->takeName(Op0); return BinaryOperator::CreateXor(NOr, - cast<Instruction>(Op1)->getOperand(1)); + ConstantInt::get(NOr->getType(), *C)); } } diff --git a/llvm/test/Transforms/InstCombine/pr32686.ll b/llvm/test/Transforms/InstCombine/pr32686.ll new file mode 100644 index 00000000000..7abda234920 --- /dev/null +++ b/llvm/test/Transforms/InstCombine/pr32686.ll @@ -0,0 +1,22 @@ +; RUN: opt -S -instcombine %s | FileCheck %s + +; CHECK-LABEL: define void @tinkywinky +; CHECK-NEXT: %patatino = load i8, i8* @a, align 1 +; CHECK-NEXT: %tobool = icmp eq i8 %patatino, 0 +; CHECK-NEXT: %1 = zext i1 %tobool to i32 +; CHECK-NEXT: %or1 = or i32 %1, or (i32 zext (i1 icmp ne (i32* bitcast (i8* @a to i32*), i32* @b) to i32), i32 2) +; CHECK-NEXT: store i32 %or1, i32* @b, align 4 +; CHECK-NEXT: ret void + +@a = external global i8 +@b = external global i32 + +define void @tinkywinky() { + %patatino = load i8, i8* @a + %tobool = icmp ne i8 %patatino, 0 + %lnot = xor i1 %tobool, true + %lnot.ext = zext i1 %lnot to i32 + %or = or i32 xor (i32 zext (i1 icmp ne (i32* bitcast (i8* @a to i32*), i32* @b) to i32), i32 2), %lnot.ext + store i32 %or, i32* @b, align 4 + ret void +} |

