mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-06 02:17:20 +00:00
ConstantFold: Shifting undef by zero results in undef
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224553 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -956,12 +956,18 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
|
|||||||
// X >>l undef -> undef
|
// X >>l undef -> undef
|
||||||
if (isa<UndefValue>(C2))
|
if (isa<UndefValue>(C2))
|
||||||
return C2;
|
return C2;
|
||||||
|
// undef >>l 0 -> undef
|
||||||
|
if (match(C2, m_Zero()))
|
||||||
|
return C1;
|
||||||
// undef >>l X -> 0
|
// undef >>l X -> 0
|
||||||
return Constant::getNullValue(C1->getType());
|
return Constant::getNullValue(C1->getType());
|
||||||
case Instruction::AShr:
|
case Instruction::AShr:
|
||||||
// X >>a undef -> undef
|
// X >>a undef -> undef
|
||||||
if (isa<UndefValue>(C2))
|
if (isa<UndefValue>(C2))
|
||||||
return C2;
|
return C2;
|
||||||
|
// undef >>a 0 -> undef
|
||||||
|
if (match(C2, m_Zero()))
|
||||||
|
return C1;
|
||||||
// TODO: undef >>a X -> undef if the shift is exact
|
// TODO: undef >>a X -> undef if the shift is exact
|
||||||
// undef >>a X -> 0
|
// undef >>a X -> 0
|
||||||
return Constant::getNullValue(C1->getType());
|
return Constant::getNullValue(C1->getType());
|
||||||
@@ -969,6 +975,9 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
|
|||||||
// X << undef -> undef
|
// X << undef -> undef
|
||||||
if (isa<UndefValue>(C2))
|
if (isa<UndefValue>(C2))
|
||||||
return C2;
|
return C2;
|
||||||
|
// undef << 0 -> undef
|
||||||
|
if (match(C2, m_Zero()))
|
||||||
|
return C1;
|
||||||
// undef << X -> 0
|
// undef << X -> 0
|
||||||
return Constant::getNullValue(C1->getType());
|
return Constant::getNullValue(C1->getType());
|
||||||
}
|
}
|
||||||
|
@@ -244,3 +244,24 @@ define i32 @test31(i32 %a) {
|
|||||||
%b = shl i32 undef, %a
|
%b = shl i32 undef, %a
|
||||||
ret i32 %b
|
ret i32 %b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; CHECK-LABEL: @test32
|
||||||
|
; CHECK: ret i32 undef
|
||||||
|
define i32 @test32(i32 %a) {
|
||||||
|
%b = shl i32 undef, 0
|
||||||
|
ret i32 %b
|
||||||
|
}
|
||||||
|
|
||||||
|
; CHECK-LABEL: @test33
|
||||||
|
; CHECK: ret i32 undef
|
||||||
|
define i32 @test33(i32 %a) {
|
||||||
|
%b = ashr i32 undef, 0
|
||||||
|
ret i32 %b
|
||||||
|
}
|
||||||
|
|
||||||
|
; CHECK-LABEL: @test34
|
||||||
|
; CHECK: ret i32 undef
|
||||||
|
define i32 @test34(i32 %a) {
|
||||||
|
%b = lshr i32 undef, 0
|
||||||
|
ret i32 %b
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user