[PATCH] D24536: SpeculativeExecution: Allow speculating compares

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 13 16:52:26 PDT 2016


arsenm created this revision.
arsenm added a subscriber: llvm-commits.
Herald added a subscriber: wdng.

https://reviews.llvm.org/D24536

Files:
  lib/Transforms/Scalar/SpeculativeExecution.cpp
  test/Transforms/SpeculativeExecution/spec-compares.ll

Index: test/Transforms/SpeculativeExecution/spec-compares.ll
===================================================================
--- /dev/null
+++ test/Transforms/SpeculativeExecution/spec-compares.ll
@@ -0,0 +1,31 @@
+; RUN: opt < %s -S -speculative-execution \
+; RUN:   -spec-exec-max-speculation-cost 4 -spec-exec-max-not-hoisted 3 \
+; RUN:   | FileCheck %s
+
+; CHECK-LABEL: @ifThen_icmp(
+; CHECK: icmp
+; CHECK: br i1 true
+define void @ifThen_icmp() {
+  br i1 true, label %a, label %b
+
+a:
+  %x = icmp eq i32 undef, undef
+  br label %b
+
+b:
+  ret void
+}
+
+; CHECK-LABEL: @ifThen_fcmp(
+; CHECK: fcmp
+; CHECK: br i1 true
+define void @ifThen_fcmp() {
+  br i1 true, label %a, label %b
+
+a:
+  %x = fcmp oeq float undef, undef
+  br label %b
+
+b:
+  ret void
+}
Index: lib/Transforms/Scalar/SpeculativeExecution.cpp
===================================================================
--- lib/Transforms/Scalar/SpeculativeExecution.cpp
+++ lib/Transforms/Scalar/SpeculativeExecution.cpp
@@ -240,6 +240,8 @@
     case Instruction::FMul:
     case Instruction::FDiv:
     case Instruction::FRem:
+    case Instruction::ICmp:
+    case Instruction::FCmp:
       return TTI.getUserCost(I);
 
     default:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24536.71270.patch
Type: text/x-patch
Size: 1219 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160913/a3a265f7/attachment.bin>


More information about the llvm-commits mailing list