[llvm] r312685 - InstSimplify: canonicalize is idempotent
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 6 18:21:43 PDT 2017
Author: arsenm
Date: Wed Sep 6 18:21:43 2017
New Revision: 312685
URL: http://llvm.org/viewvc/llvm-project?rev=312685&view=rev
Log:
InstSimplify: canonicalize is idempotent
Modified:
llvm/trunk/lib/Analysis/InstructionSimplify.cpp
llvm/trunk/test/Transforms/InstSimplify/call.ll
Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=312685&r1=312684&r2=312685&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Wed Sep 6 18:21:43 2017
@@ -4268,6 +4268,7 @@ static bool IsIdempotent(Intrinsic::ID I
case Intrinsic::rint:
case Intrinsic::nearbyint:
case Intrinsic::round:
+ case Intrinsic::canonicalize:
return true;
}
}
Modified: llvm/trunk/test/Transforms/InstSimplify/call.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/call.ll?rev=312685&r1=312684&r2=312685&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/call.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/call.ll Wed Sep 6 18:21:43 2017
@@ -242,6 +242,7 @@ declare float @llvm.ceil.f32(float) noun
declare float @llvm.trunc.f32(float) nounwind readnone
declare float @llvm.rint.f32(float) nounwind readnone
declare float @llvm.nearbyint.f32(float) nounwind readnone
+declare float @llvm.canonicalize.f32(float) nounwind readnone
; Test idempotent intrinsics
define float @test_idempotence(float %a) {
@@ -252,12 +253,14 @@ define float @test_idempotence(float %a)
; CHECK-NEXT: [[D0:%.*]] = call float @llvm.trunc.f32(float [[A]])
; CHECK-NEXT: [[E0:%.*]] = call float @llvm.rint.f32(float [[A]])
; CHECK-NEXT: [[F0:%.*]] = call float @llvm.nearbyint.f32(float [[A]])
+; CHECK-NEXT: [[G0:%.*]] = call float @llvm.canonicalize.f32(float [[A]])
; CHECK-NEXT: [[R0:%.*]] = fadd float [[A0]], [[B0]]
; CHECK-NEXT: [[R1:%.*]] = fadd float [[R0]], [[C0]]
; CHECK-NEXT: [[R2:%.*]] = fadd float [[R1]], [[D0]]
; CHECK-NEXT: [[R3:%.*]] = fadd float [[R2]], [[E0]]
; CHECK-NEXT: [[R4:%.*]] = fadd float [[R3]], [[F0]]
-; CHECK-NEXT: ret float [[R4]]
+; CHECK-NEXT: [[R5:%.*]] = fadd float [[R4]], [[G0]]
+; CHECK-NEXT: ret float [[R5]]
;
%a0 = call float @llvm.fabs.f32(float %a)
@@ -278,13 +281,17 @@ define float @test_idempotence(float %a)
%f0 = call float @llvm.nearbyint.f32(float %a)
%f1 = call float @llvm.nearbyint.f32(float %f0)
+ %g0 = call float @llvm.canonicalize.f32(float %a)
+ %g1 = call float @llvm.canonicalize.f32(float %g0)
+
%r0 = fadd float %a1, %b1
%r1 = fadd float %r0, %c1
%r2 = fadd float %r1, %d1
%r3 = fadd float %r2, %e1
%r4 = fadd float %r3, %f1
+ %r5 = fadd float %r4, %g1
- ret float %r4
+ ret float %r5
}
define i8* @operator_new() {
More information about the llvm-commits
mailing list