[llvm] r186758 - Have InlineCost check constant fcmps
Matt Arsenault
Matthew.Arsenault at amd.com
Fri Jul 19 21:09:00 PDT 2013
Author: arsenm
Date: Fri Jul 19 23:09:00 2013
New Revision: 186758
URL: http://llvm.org/viewvc/llvm-project?rev=186758&view=rev
Log:
Have InlineCost check constant fcmps
Modified:
llvm/trunk/lib/Analysis/IPA/InlineCost.cpp
llvm/trunk/test/Transforms/Inline/inline_constprop.ll
Modified: llvm/trunk/lib/Analysis/IPA/InlineCost.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/InlineCost.cpp?rev=186758&r1=186757&r2=186758&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/IPA/InlineCost.cpp (original)
+++ llvm/trunk/lib/Analysis/IPA/InlineCost.cpp Fri Jul 19 23:09:00 2013
@@ -124,7 +124,7 @@ class CallAnalyzer : public InstVisitor<
bool visitIntToPtr(IntToPtrInst &I);
bool visitCastInst(CastInst &I);
bool visitUnaryInstruction(UnaryInstruction &I);
- bool visitICmp(ICmpInst &I);
+ bool visitCmpInst(CmpInst &I);
bool visitSub(BinaryOperator &I);
bool visitBinaryOperator(BinaryOperator &I);
bool visitLoad(LoadInst &I);
@@ -490,7 +490,7 @@ bool CallAnalyzer::visitUnaryInstruction
return false;
}
-bool CallAnalyzer::visitICmp(ICmpInst &I) {
+bool CallAnalyzer::visitCmpInst(CmpInst &I) {
Value *LHS = I.getOperand(0), *RHS = I.getOperand(1);
// First try to handle simplified comparisons.
if (!isa<Constant>(LHS))
@@ -499,12 +499,16 @@ bool CallAnalyzer::visitICmp(ICmpInst &I
if (!isa<Constant>(RHS))
if (Constant *SimpleRHS = SimplifiedValues.lookup(RHS))
RHS = SimpleRHS;
- if (Constant *CLHS = dyn_cast<Constant>(LHS))
+ if (Constant *CLHS = dyn_cast<Constant>(LHS)) {
if (Constant *CRHS = dyn_cast<Constant>(RHS))
- if (Constant *C = ConstantExpr::getICmp(I.getPredicate(), CLHS, CRHS)) {
+ if (Constant *C = ConstantExpr::getCompare(I.getPredicate(), CLHS, CRHS)) {
SimplifiedValues[&I] = C;
return true;
}
+ }
+
+ if (I.getOpcode() == Instruction::FCmp)
+ return false;
// Otherwise look for a comparison between constant offset pointers with
// a common base.
Modified: llvm/trunk/test/Transforms/Inline/inline_constprop.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/inline_constprop.ll?rev=186758&r1=186757&r2=186758&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/Inline/inline_constprop.ll (original)
+++ llvm/trunk/test/Transforms/Inline/inline_constprop.ll Fri Jul 19 23:09:00 2013
@@ -187,6 +187,37 @@ bb.false:
ret i64 %y8
}
+define float @caller6() {
+; Check that we can constant-prop through fcmp instructions
+;
+; CHECK-LABEL: @caller6(
+; CHECK-NOT: call
+; CHECK: ret
+ %x = call float @callee6(float 42.0)
+ ret float %x
+}
+
+define float @callee6(float %x) {
+ %icmp = fcmp ugt float %x, 42.0
+ br i1 %icmp, label %bb.true, label %bb.false
+
+bb.true:
+ ; This block musn't be counted in the inline cost.
+ %x1 = fadd float %x, 1.0
+ %x2 = fadd float %x1, 1.0
+ %x3 = fadd float %x2, 1.0
+ %x4 = fadd float %x3, 1.0
+ %x5 = fadd float %x4, 1.0
+ %x6 = fadd float %x5, 1.0
+ %x7 = fadd float %x6, 1.0
+ %x8 = fadd float %x7, 1.0
+ ret float %x8
+
+bb.false:
+ ret float %x
+}
+
+
define i32 @PR13412.main() {
; This is a somewhat complicated three layer subprogram that was reported to
More information about the llvm-commits
mailing list