Commit 53c5e609 by Matt Wala

Fix legalization of source operand to bsr and bsf.

The source operand to bsr and bsf must be in a register or memory. BUG=none R=jvoung@chromium.org Review URL: https://codereview.chromium.org/407093014
parent 927cc171
......@@ -3014,10 +3014,11 @@ void TargetX8632::lowerCountZeros(bool Cttz, Type Ty, Variable *Dest,
// bit position conversion, and the speculation is reversed.
assert(Ty == IceType_i32 || Ty == IceType_i64);
Variable *T = makeReg(IceType_i32);
Operand *FirstValRM = legalize(FirstVal, Legal_Mem | Legal_Reg);
if (Cttz) {
_bsf(T, FirstVal);
_bsf(T, FirstValRM);
} else {
_bsr(T, FirstVal);
_bsr(T, FirstValRM);
}
Variable *T_Dest = makeReg(IceType_i32);
Constant *ThirtyTwo = Ctx->getConstantInt(IceType_i32, 32);
......
......@@ -8,9 +8,8 @@
; some code is optimized out.
; RUN: %llvm2ice -O2 --verbose none %s | FileCheck %s --check-prefix=CHECKO2REM
; TODO: The next two lines cause this test to fail.
; RUIN: %llvm2ice -O2 --verbose none %s | llvm-mc -x86-asm-syntax=intel
; RUIN: %llvm2ice -Om1 --verbose none %s | llvm-mc -x86-asm-syntax=intel
; RUN: %llvm2ice -O2 --verbose none %s | llvm-mc -x86-asm-syntax=intel
; RUN: %llvm2ice -Om1 --verbose none %s | llvm-mc -x86-asm-syntax=intel
; RUN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
......@@ -310,8 +309,10 @@ entry:
ret i32 %r
}
; Could potentially constant fold this, but the front-end should have done that.
; The dest operand must be a register and the source operand must be a register
; or memory.
; CHECK-LABEL: test_ctlz_32_const
; CHECK: bsr
; CHECK: bsr e{{.*}}, {{.*}}e{{.*}}
define i32 @test_ctlz_32_ignored(i32 %x) {
entry:
......@@ -346,8 +347,9 @@ entry:
ret i32 %r2
}
; CHECK-LABEL: test_ctlz_64_const
; CHECK: bsr
; CHECK: bsr
; CHECK: bsr e{{.*}}, {{.*}}e{{.*}}
; CHECK: bsr e{{.*}}, {{.*}}e{{.*}}
define i32 @test_ctlz_64_ignored(i64 %x) {
entry:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment