// If this is an AND or OR with 0 or -1, it doesn't matter that the other
// operand is overdefined.
- if (I.getOpcode() == Instruction::And || I.getOpcode() == Instruction::Or) {
+ if (I.getOpcode() == Instruction::And || I.getOpcode() == Instruction::Mul ||
+ I.getOpcode() == Instruction::Or) {
LatticeVal *NonOverdefVal = nullptr;
if (!V1State.isOverdefined())
NonOverdefVal = &V1State;
if (NonOverdefVal->isUnknown())
return;
- if (I.getOpcode() == Instruction::And) {
+ if (I.getOpcode() == Instruction::And ||
+ I.getOpcode() == Instruction::Mul) {
// X and 0 = 0
+ // X * 0 = 0
if (NonOverdefVal->getConstant()->isNullValue())
return markConstant(IV, &I, NonOverdefVal->getConstant());
} else {
; RUN: opt < %s -sccp -S | FileCheck %s
-; Test that SCCP has basic knowledge of when and/or nuke overdefined values.
+; Test that SCCP has basic knowledge of when and/or/mul nuke overdefined values.
; CHECK-LABEL: test
; CHECK: ret i32 0
%Y = or i32 %X, undef
ret i32 %Y
}
+
+; CHECK-LABEL: test5
+; CHECK: ret i32 0
+define i32 @test5(i32 %foo) {
+ %patatino = mul i32 %foo, undef
+ ret i32 %patatino
+}