So model the cost of materializing the constant operand C as the minimum of
C and ~C.
llvm-svn: 280929
Idx == 1)
return 0;
+ if (Opcode == Instruction::And)
+ // Conversion to BIC is free, and means we can use ~Imm instead.
+ return std::min(getIntImmCost(Imm, Ty), getIntImmCost(~Imm, Ty));
+
return getIntImmCost(Imm, Ty);
}
ret:
ret void
}
+
+; CHECK: Function: h
+; CHECK-NOT: Collect constant i32 -193 from
+define void @h(i1 %cond, i32 %p, i32 %q) {
+entry:
+ %a = and i32 %p, 4294967103
+ call void @g(i32 %a)
+ br i1 %cond, label %true, label %ret
+
+true:
+ %b = and i32 %q, 4294967103
+ call void @g(i32 %b)
+ br label %ret
+
+ret:
+ ret void
+}
+