unsigned MOVCCi;
// Used for G_SELECT
- unsigned CMPri;
unsigned MOVCCr;
unsigned TSTri;
STORE_OPCODE(MOVi, MOVi);
STORE_OPCODE(MOVCCi, MOVCCi);
- STORE_OPCODE(CMPri, CMPri);
STORE_OPCODE(MOVCCr, MOVCCr);
STORE_OPCODE(TSTri, TSTri);
auto InsertBefore = std::next(MIB->getIterator());
auto &DbgLoc = MIB->getDebugLoc();
- // Compare the condition to 0.
+ // Compare the condition to 1.
auto CondReg = MIB->getOperand(1).getReg();
assert(validReg(MRI, CondReg, 1, ARM::GPRRegBankID) &&
"Unsupported types for select operation");
- auto CmpI = BuildMI(MBB, InsertBefore, DbgLoc, TII.get(Opcodes.CMPri))
+ auto CmpI = BuildMI(MBB, InsertBefore, DbgLoc, TII.get(Opcodes.TSTri))
.addUse(CondReg)
- .addImm(0)
+ .addImm(1)
.add(predOps(ARMCC::AL));
if (!constrainSelectedInstRegOperands(*CmpI, TII, TRI, RBI))
return false;
%2(s1) = G_TRUNC %1(s32)
%3(s32) = G_SELECT %2(s1), %0, %1
- ; CHECK: CMPri [[VREGY]], 0, 14, $noreg, implicit-def $cpsr
+ ; CHECK: TSTri [[VREGY]], 1, 14, $noreg, implicit-def $cpsr
; CHECK: [[RES:%[0-9]+]]:gpr = MOVCCr [[VREGX]], [[VREGY]], 0, $cpsr
$r0 = COPY %3(s32)
%3(s1) = G_TRUNC %2(s32)
%4(p0) = G_SELECT %3(s1), %0, %1
- ; CHECK: CMPri [[VREGC]], 0, 14, $noreg, implicit-def $cpsr
+ ; CHECK: TSTri [[VREGC]], 1, 14, $noreg, implicit-def $cpsr
; CHECK: [[RES:%[0-9]+]]:gpr = MOVCCr [[VREGX]], [[VREGY]], 0, $cpsr
$r0 = COPY %4(p0)
define arm_aapcscc i32 @test_select_i32(i32 %a, i32 %b, i1 %cond) {
; CHECK-LABEL: test_select_i32
-; CHECK: cmp r2, #0
+; CHECK: tst r2, #1
; CHECK: moveq r0, r1
; CHECK: bx lr
entry:
define arm_aapcscc i32* @test_select_ptr(i32* %a, i32* %b, i1 %cond) {
; CHECK-LABEL: test_select_ptr
-; CHECK: cmp r2, #0
+; CHECK: tst r2, #1
; CHECK: moveq r0, r1
; CHECK: bx lr
entry:
; CHECK: [[VREGC:%[0-9]+]]:gprnopc = COPY [[VREGY]]
%3(s32) = G_SELECT %2(s1), %0, %1
- ; CHECK: t2CMPri [[VREGC]], 0, 14, $noreg, implicit-def $cpsr
+ ; CHECK: t2TSTri [[VREGC]], 1, 14, $noreg, implicit-def $cpsr
; CHECK: [[RES:%[0-9]+]]:rgpr = t2MOVCCr [[VREGX]], [[VREGY]], 0, $cpsr
$r0 = COPY %3(s32)
; CHECK: [[VREGC:%[0-9]+]]:gprnopc = COPY [[VREGC32]]
%4(p0) = G_SELECT %3(s1), %0, %1
- ; CHECK: t2CMPri [[VREGC]], 0, 14, $noreg, implicit-def $cpsr
+ ; CHECK: t2TSTri [[VREGC]], 1, 14, $noreg, implicit-def $cpsr
; CHECK: [[RES:%[0-9]+]]:rgpr = t2MOVCCr [[VREGX]], [[VREGY]], 0, $cpsr
$r0 = COPY %4(p0)