mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 20:09:46 +00:00
[InstCombine] Fold cttz of abs intrinsic
Same as the existing fold for SPF_ABS. We don't need to explicitly handle the NABS variant, as we'll first fold away the neg in that case.
This commit is contained in:
parent
78708a857e
commit
5750a482e4
@ -428,6 +428,9 @@ static Instruction *foldCttzCtlz(IntrinsicInst &II, InstCombinerImpl &IC) {
|
||||
SelectPatternFlavor SPF = matchSelectPattern(Op0, X, Y).Flavor;
|
||||
if (SPF == SPF_ABS || SPF == SPF_NABS)
|
||||
return IC.replaceOperand(II, 0, X);
|
||||
|
||||
if (match(Op0, m_Intrinsic<Intrinsic::abs>(m_Value(X))))
|
||||
return IC.replaceOperand(II, 0, X);
|
||||
}
|
||||
|
||||
KnownBits Known = IC.computeKnownBits(Op0, 0, &II);
|
||||
|
@ -218,8 +218,7 @@ define <2 x i64> @no_cttz_nabs_vec(<2 x i64> %x) {
|
||||
|
||||
define i32 @cttz_abs_intrin(i32 %x) {
|
||||
; CHECK-LABEL: @cttz_abs_intrin(
|
||||
; CHECK-NEXT: [[A:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 false)
|
||||
; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.cttz.i32(i32 [[A]], i1 false), [[RNG0]]
|
||||
; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.cttz.i32(i32 [[X:%.*]], i1 false), [[RNG0]]
|
||||
; CHECK-NEXT: ret i32 [[R]]
|
||||
;
|
||||
%a = call i32 @llvm.abs.i32(i32 %x, i1 false)
|
||||
@ -229,8 +228,7 @@ define i32 @cttz_abs_intrin(i32 %x) {
|
||||
|
||||
define i32 @cttz_nabs_intrin(i32 %x) {
|
||||
; CHECK-LABEL: @cttz_nabs_intrin(
|
||||
; CHECK-NEXT: [[A:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 false)
|
||||
; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.cttz.i32(i32 [[A]], i1 false), [[RNG0]]
|
||||
; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.cttz.i32(i32 [[X:%.*]], i1 false), [[RNG0]]
|
||||
; CHECK-NEXT: ret i32 [[R]]
|
||||
;
|
||||
%a = call i32 @llvm.abs.i32(i32 %x, i1 false)
|
||||
|
Loading…
Reference in New Issue
Block a user