summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/X86/early-ifcvt.ll
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2013-01-03 06:40:20 +0000
committerCraig Topper <craig.topper@gmail.com>2013-01-03 06:40:20 +0000
commit7c27cc9fd03803f5766079e0089b03a733b72b70 (patch)
tree131f537ddc171ad557d612e08dcf3587ac78d02b /llvm/test/CodeGen/X86/early-ifcvt.ll
parentc8c12bc0ff9c9563a2b101b639948ca3629d949f (diff)
downloadbcm5719-llvm-7c27cc9fd03803f5766079e0089b03a733b72b70.tar.gz
bcm5719-llvm-7c27cc9fd03803f5766079e0089b03a733b72b70.zip
Mark DIV/IDIV instructions hasSideEffects=1 because they can trap when dividing by 0. This is needed to keep early if conversion from moving them across basic blocks.
llvm-svn: 171461
Diffstat (limited to 'llvm/test/CodeGen/X86/early-ifcvt.ll')
-rw-r--r--llvm/test/CodeGen/X86/early-ifcvt.ll32
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/early-ifcvt.ll b/llvm/test/CodeGen/X86/early-ifcvt.ll
index 2e1852d3e3a..b3a20c3ee0b 100644
--- a/llvm/test/CodeGen/X86/early-ifcvt.ll
+++ b/llvm/test/CodeGen/X86/early-ifcvt.ll
@@ -142,3 +142,35 @@ save_state_and_return:
}
declare void @BZ2_bz__AssertH__fail()
+
+
+; Make sure we don't speculate on div/idiv instructions
+; CHECK: test_idiv
+; CHECK-NOT: cmov
+define i32 @test_idiv(i32 %a, i32 %b) nounwind uwtable readnone ssp {
+ %1 = icmp eq i32 %b, 0
+ br i1 %1, label %4, label %2
+
+; <label>:2 ; preds = %0
+ %3 = sdiv i32 %a, %b
+ br label %4
+
+; <label>:4 ; preds = %0, %2
+ %5 = phi i32 [ %3, %2 ], [ %a, %0 ]
+ ret i32 %5
+}
+
+; CHECK: test_div
+; CHECK-NOT: cmov
+define i32 @test_div(i32 %a, i32 %b) nounwind uwtable readnone ssp {
+ %1 = icmp eq i32 %b, 0
+ br i1 %1, label %4, label %2
+
+; <label>:2 ; preds = %0
+ %3 = udiv i32 %a, %b
+ br label %4
+
+; <label>:4 ; preds = %0, %2
+ %5 = phi i32 [ %3, %2 ], [ %a, %0 ]
+ ret i32 %5
+}
OpenPOWER on IntegriCloud