Zero is usually a nicer constant to have than -1.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223969
91177308-0d34-0410-b5e6-
96231b3b80d8
if (match(Op0, m_AllOnes()))
return Op0;
- // undef >>a X -> all ones
+ // undef >>a X -> 0
// undef >>a X -> undef (if it's exact)
if (match(Op0, m_Undef()))
return isExact ? UndefValue::get(Op0->getType())
- : Constant::getAllOnesValue(Op0->getType());
+ : Constant::getNullValue(Op0->getType());
// (X << A) >> A -> X
Value *X;
// X >>a undef -> undef
if (isa<UndefValue>(C2))
return C2;
- // undef >>a X -> all ones
- return Constant::getAllOnesValue(C1->getType());
+ // TODO: undef >>a X -> undef if the shift is exact
+ // undef >>a X -> 0
+ return Constant::getNullValue(C1->getType());
case Instruction::Shl:
// X << undef -> undef
if (isa<UndefValue>(C2))
define i32 @test5b() {
; CHECK-LABEL: @test5b(
-; CHECK: ret i32 -1
+; CHECK: ret i32 0
%B = ashr i32 undef, 2 ;; top two bits must be equal, so not undef
ret i32 %B
}
define i32 @test5b2(i32 %A) {
; CHECK-LABEL: @test5b2(
-; CHECK: ret i32 -1
+; CHECK: ret i32 0
%B = ashr i32 undef, %A ;; top %A bits must be equal, so not undef
ret i32 %B
}