Skip to content

Commit

Permalink
[ARM] GlobalISel: Fix oversight in G_FCMP legalization
Browse files Browse the repository at this point in the history
We used to forget to erase the original instruction when replacing a
G_FCMP true/false. Fix this bug and make sure the tests check for it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307639 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
rovka committed Jul 11, 2017
1 parent ec48fd1 commit f4f832c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/Target/ARM/ARMLegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ bool ARMLegalizerInfo::legalizeCustom(MachineInstr &MI,
"Predicate needs libcalls, but none specified");
MIRBuilder.buildConstant(OriginalResult,
Predicate == CmpInst::FCMP_TRUE ? 1 : 0);
MI.eraseFromParent();
return true;
}

Expand Down
8 changes: 8 additions & 0 deletions test/CodeGen/ARM/GlobalISel/arm-legalize-fp.mir
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,10 @@ body: |
; CHECK-DAG: [[Y:%[0-9]+]](s32) = COPY %r1
%2(s1) = G_FCMP floatpred(true), %0(s32), %1
; HARD: [[R:%[0-9]+]](s1) = G_FCMP floatpred(true), [[X]](s32), [[Y]]
; SOFT-NOT: G_FCMP
; SOFT: [[REXT:%[0-9]+]](s32) = G_CONSTANT i32 -1
; SOFT: [[R:%[0-9]+]](s1) = G_TRUNC [[REXT]](s32)
; SOFT-NOT: G_FCMP
%3(s32) = G_ZEXT %2(s1)
; CHECK: [[REXT:%[0-9]+]](s32) = G_ZEXT [[R]](s1)
%r0 = COPY %3(s32)
Expand Down Expand Up @@ -368,8 +370,10 @@ body: |
; CHECK-DAG: [[Y:%[0-9]+]](s32) = COPY %r1
%2(s1) = G_FCMP floatpred(false), %0(s32), %1
; HARD: [[R:%[0-9]+]](s1) = G_FCMP floatpred(false), [[X]](s32), [[Y]]
; SOFT-NOT: G_FCMP
; SOFT: [[REXT:%[0-9]+]](s32) = G_CONSTANT i32 0
; SOFT: [[R:%[0-9]+]](s1) = G_TRUNC [[REXT]](s32)
; SOFT-NOT: G_FCMP
%3(s32) = G_ZEXT %2(s1)
; CHECK: [[REXT:%[0-9]+]](s32) = G_ZEXT [[R]](s1)
%r0 = COPY %3(s32)
Expand Down Expand Up @@ -984,8 +988,10 @@ body: |
; HARD-DAG: [[Y:%[0-9]+]](s64) = G_MERGE_VALUES [[Y0]](s32), [[Y1]](s32)
%6(s1) = G_FCMP floatpred(true), %4(s64), %5
; HARD: [[R:%[0-9]+]](s1) = G_FCMP floatpred(true), [[X]](s64), [[Y]]
; SOFT-NOT: G_FCMP
; SOFT: [[REXT:%[0-9]+]](s32) = G_CONSTANT i32 -1
; SOFT: [[R:%[0-9]+]](s1) = G_TRUNC [[REXT]](s32)
; SOFT-NOT: G_FCMP
%7(s32) = G_ZEXT %6(s1)
; CHECK: [[REXT:%[0-9]+]](s32) = G_ZEXT [[R]](s1)
%r0 = COPY %7(s32)
Expand Down Expand Up @@ -1027,8 +1033,10 @@ body: |
; HARD-DAG: [[Y:%[0-9]+]](s64) = G_MERGE_VALUES [[Y0]](s32), [[Y1]](s32)
%6(s1) = G_FCMP floatpred(false), %4(s64), %5
; HARD: [[R:%[0-9]+]](s1) = G_FCMP floatpred(false), [[X]](s64), [[Y]]
; SOFT-NOT: G_FCMP
; SOFT: [[REXT:%[0-9]+]](s32) = G_CONSTANT i32 0
; SOFT: [[R:%[0-9]+]](s1) = G_TRUNC [[REXT]](s32)
; SOFT-NOT: G_FCMP
%7(s32) = G_ZEXT %6(s1)
; CHECK: [[REXT:%[0-9]+]](s32) = G_ZEXT [[R]](s1)
%r0 = COPY %7(s32)
Expand Down

0 comments on commit f4f832c

Please sign in to comment.