[PATCH] D34743: [AArch64] AArch64CondBrTuningPass generates wrong branch instructions

Alexandros Lamprineas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 28 01:45:30 PDT 2017


labrinea created this revision.
Herald added subscribers: kristof.beyls, javed.absar, rengolin, aemerson.

Some conditional branch instructions generated by this pass are checking the wrong condition code. The instructions TBZ and TBNZ are transformed into B.GE and B.LT instead of B.PL and B.MI respectively. They should only be checking the Negative bit.


https://reviews.llvm.org/D34743

Files:
  lib/Target/AArch64/AArch64CondBrTuning.cpp
  test/CodeGen/AArch64/cond-br-tuning.ll


Index: test/CodeGen/AArch64/cond-br-tuning.ll
===================================================================
--- test/CodeGen/AArch64/cond-br-tuning.ll
+++ test/CodeGen/AArch64/cond-br-tuning.ll
@@ -83,7 +83,7 @@
 
 ; CHECK-LABEL: test_add_tbz:
 ; CHECK: adds
-; CHECK: b.ge
+; CHECK: b.pl
 ; CHECK: ret
 define void @test_add_tbz(i32 %a, i32 %b, i32* %ptr) {
 entry:
@@ -99,7 +99,7 @@
 
 ; CHECK-LABEL: test_subs_tbz:
 ; CHECK: subs
-; CHECK: b.ge
+; CHECK: b.pl
 ; CHECK: ret
 define void @test_subs_tbz(i32 %a, i32 %b, i32* %ptr) {
 entry:
@@ -115,7 +115,7 @@
 
 ; CHECK-LABEL: test_add_tbnz
 ; CHECK: adds
-; CHECK: b.lt
+; CHECK: b.mi
 ; CHECK: ret
 define void @test_add_tbnz(i32 %a, i32 %b, i32* %ptr) {
 entry:
@@ -131,7 +131,7 @@
 
 ; CHECK-LABEL: test_subs_tbnz
 ; CHECK: subs
-; CHECK: b.lt
+; CHECK: b.mi
 ; CHECK: ret
 define void @test_subs_tbnz(i32 %a, i32 %b, i32* %ptr) {
 entry:
Index: lib/Target/AArch64/AArch64CondBrTuning.cpp
===================================================================
--- lib/Target/AArch64/AArch64CondBrTuning.cpp
+++ lib/Target/AArch64/AArch64CondBrTuning.cpp
@@ -129,11 +129,11 @@
     break;
   case AArch64::TBZW:
   case AArch64::TBZX:
-    CC = AArch64CC::GE;
+    CC = AArch64CC::PL;
     break;
   case AArch64::TBNZW:
   case AArch64::TBNZX:
-    CC = AArch64CC::LT;
+    CC = AArch64CC::MI;
     break;
   }
   return BuildMI(*MI.getParent(), MI, MI.getDebugLoc(), TII->get(AArch64::Bcc))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34743.104359.patch
Type: text/x-patch
Size: 1452 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170628/90468c8f/attachment.bin>


More information about the llvm-commits mailing list