This reverts the revert commit 408c4408facc3a79ee4ff7e9983cc972f797e176. This version of the patch includes a fix for a crash caused by treating ICmp/FCmp constant expressions as instructions. Original message: On some targets, like AArch64, vector selects can be efficiently lowered if the vector condition is a compare with a supported predicate. This patch adds a new argument to getCmpSelInstrCost, to indicate the predicate of the feeding select condition. Note that it is not sufficient to use the context instruction when querying the cost of a vector select starting from a scalar one, because the condition of the vector select could be composed of compares with different predicates. This change greatly improves modeling the costs of certain compare/select patterns on AArch64. I am also planning on putting up patches to make use of the new argument in SLPVectorizer & LV.
24 lines
827 B
LLVM
24 lines
827 B
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
; RUN: opt -simplifycfg -S %s | FileCheck %s
|
|
|
|
@glob = internal constant [5 x i8*] zeroinitializer, align 16
|
|
|
|
; Make sure simplifycfg does not crash when dealing with icmp constant
|
|
; expressions.
|
|
define i1 @test(i1 %c) {
|
|
; CHECK-LABEL: @test(
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[C:%.*]], i1 false, i1 icmp ult (i8** getelementptr inbounds ([5 x i8*], [5 x i8*]* @glob, i64 0, i64 0), i8** inttoptr (i64 -40 to i8**))
|
|
; CHECK-NEXT: ret i1 [[SPEC_SELECT]]
|
|
;
|
|
entry:
|
|
br i1 %c, label %if.then, label %exit
|
|
|
|
if.then:
|
|
br label %exit
|
|
|
|
exit:
|
|
%p = phi i1 [ false, %if.then ], [ icmp ult (i8** getelementptr inbounds ([5 x i8*], [5 x i8*]* @glob, i64 0, i64 0), i8** inttoptr (i64 -40 to i8**)), %entry ]
|
|
ret i1 %p
|
|
}
|