mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-05 17:39:16 +00:00
[pr19636] Fix known bit computation in urem instruction with power of two.
Patch by Andrey Kuharev. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209902 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3a45d4c621
commit
6319c0c520
@ -2185,8 +2185,11 @@ void SelectionDAG::computeKnownBits(SDValue Op, APInt &KnownZero,
|
||||
const APInt &RA = Rem->getAPIntValue();
|
||||
if (RA.isPowerOf2()) {
|
||||
APInt LowBits = (RA - 1);
|
||||
KnownZero |= ~LowBits;
|
||||
computeKnownBits(Op.getOperand(0), KnownZero, KnownOne,Depth+1);
|
||||
computeKnownBits(Op.getOperand(0), KnownZero2, KnownOne2, Depth + 1);
|
||||
|
||||
// The upper bits are all zero, the lower ones are unchanged.
|
||||
KnownZero = KnownZero2 | ~LowBits;
|
||||
KnownOne = KnownOne2 & LowBits;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
14
test/CodeGen/X86/computeKnownBits_urem.ll
Normal file
14
test/CodeGen/X86/computeKnownBits_urem.ll
Normal file
@ -0,0 +1,14 @@
|
||||
; RUN: llc -mtriple=x86_64-linux < %s | FileCheck %s
|
||||
define i32 @main() #0 {
|
||||
entry:
|
||||
%a = alloca i32, align 4
|
||||
store i32 1, i32* %a, align 4
|
||||
%0 = load i32* %a, align 4
|
||||
%or = or i32 1, %0
|
||||
%and = and i32 1, %or
|
||||
%rem = urem i32 %and, 1
|
||||
%add = add i32 %rem, 1
|
||||
ret i32 %add
|
||||
}
|
||||
; CHECK: $1, %eax
|
||||
; CHECK-NEXT: retq
|
Loading…
x
Reference in New Issue
Block a user