not assume this (for example in case more transforms get added below
it). Suggested by Frits van Bommel.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122332
91177308-0d34-0410-b5e6-
96231b3b80d8
/// i1 add -> xor.
if (MaxRecurse && Op0->getType()->isIntegerTy(1))
/// i1 add -> xor.
if (MaxRecurse && Op0->getType()->isIntegerTy(1))
- return SimplifyXorInst(Op0, Op1, TD, DT, MaxRecurse-1);
+ if (Value *V = SimplifyXorInst(Op0, Op1, TD, DT, MaxRecurse-1))
+ return V;
// Try some generic simplifications for associative operations.
if (Value *V = SimplifyAssociativeBinOp(Instruction::Add, Op0, Op1, TD, DT,
// Try some generic simplifications for associative operations.
if (Value *V = SimplifyAssociativeBinOp(Instruction::Add, Op0, Op1, TD, DT,
/// i1 sub -> xor.
if (MaxRecurse && Op0->getType()->isIntegerTy(1))
/// i1 sub -> xor.
if (MaxRecurse && Op0->getType()->isIntegerTy(1))
- return SimplifyXorInst(Op0, Op1, TD, DT, MaxRecurse-1);
+ if (Value *V = SimplifyXorInst(Op0, Op1, TD, DT, MaxRecurse-1))
+ return V;
// Mul distributes over Sub. Try some generic simplifications based on this.
if (Value *V = FactorizeBinOp(Instruction::Sub, Op0, Op1, Instruction::Mul,
// Mul distributes over Sub. Try some generic simplifications based on this.
if (Value *V = FactorizeBinOp(Instruction::Sub, Op0, Op1, Instruction::Mul,
/// i1 mul -> and.
if (MaxRecurse && Op0->getType()->isIntegerTy(1))
/// i1 mul -> and.
if (MaxRecurse && Op0->getType()->isIntegerTy(1))
- return SimplifyAndInst(Op0, Op1, TD, DT, MaxRecurse-1);
+ if (Value *V = SimplifyAndInst(Op0, Op1, TD, DT, MaxRecurse-1))
+ return V;
// Try some generic simplifications for associative operations.
if (Value *V = SimplifyAssociativeBinOp(Instruction::Mul, Op0, Op1, TD, DT,
// Try some generic simplifications for associative operations.
if (Value *V = SimplifyAssociativeBinOp(Instruction::Mul, Op0, Op1, TD, DT,
--- /dev/null
+; RUN: opt < %s -instsimplify -S | FileCheck %s
+
+define i1 @add(i1 %x) {
+; CHECK: @add
+ %z = add i1 %x, %x
+ ret i1 %z
+; CHECK: ret i1 false
+}
+
+define i1 @sub(i1 %x) {
+; CHECK: @sub
+ %z = sub i1 false, %x
+ ret i1 %z
+; CHECK: ret i1 %x
+}
+
+define i1 @mul(i1 %x) {
+; CHECK: @mul
+ %z = mul i1 %x, %x
+ ret i1 %z
+; CHECK: ret i1 %x
+}