[GlobalISel][IRTranslator] Fix crash on translation of fneg.

When the fneg IR instruction was added the code to do translation wasn't
tested, and tried to get an invalid operand.

llvm-svn: 352296
This commit is contained in:
Amara Emerson 2019-01-26 23:47:09 +00:00
parent 26a6c74fbe
commit 203760ab9c
2 changed files with 11 additions and 1 deletions

View File

@ -343,7 +343,7 @@ bool IRTranslator::translateFSub(const User &U, MachineIRBuilder &MIRBuilder) {
bool IRTranslator::translateFNeg(const User &U, MachineIRBuilder &MIRBuilder) {
MIRBuilder.buildInstr(TargetOpcode::G_FNEG)
.addDef(getOrCreateVReg(U))
.addUse(getOrCreateVReg(*U.getOperand(1)));
.addUse(getOrCreateVReg(*U.getOperand(0)));
return true;
}

View File

@ -824,6 +824,16 @@ define float @test_frem(float %arg1, float %arg2) {
ret float %res
}
; CHECK-LABEL: name: test_fneg
; CHECK: [[ARG1:%[0-9]+]]:_(s32) = COPY $s0
; CHECK-NEXT: [[RES:%[0-9]+]]:_(s32) = G_FNEG [[ARG1]]
; CHECK-NEXT: $s0 = COPY [[RES]]
; CHECK-NEXT: RET_ReallyLR implicit $s0
define float @test_fneg(float %arg1) {
%res = fneg float %arg1
ret float %res
}
; CHECK-LABEL: name: test_sadd_overflow
; CHECK: [[LHS:%[0-9]+]]:_(s32) = COPY $w0
; CHECK: [[RHS:%[0-9]+]]:_(s32) = COPY $w1