[PATCH] D35222: InstSimplify: canonicalize is idempotent

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 10 13:36:40 PDT 2017


arsenm created this revision.
Herald added a subscriber: wdng.

https://reviews.llvm.org/D35222

Files:
  lib/Analysis/InstructionSimplify.cpp
  test/Transforms/InstSimplify/call.ll


Index: test/Transforms/InstSimplify/call.ll
===================================================================
--- test/Transforms/InstSimplify/call.ll
+++ test/Transforms/InstSimplify/call.ll
@@ -242,6 +242,7 @@
 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) {
@@ -278,13 +279,17 @@
   %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() {
Index: lib/Analysis/InstructionSimplify.cpp
===================================================================
--- lib/Analysis/InstructionSimplify.cpp
+++ lib/Analysis/InstructionSimplify.cpp
@@ -4297,6 +4297,7 @@
   case Intrinsic::rint:
   case Intrinsic::nearbyint:
   case Intrinsic::round:
+  case Intrinsic::canonicalize:
     return true;
   }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35222.105915.patch
Type: text/x-patch
Size: 1359 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170710/0a5ba2ae/attachment.bin>


More information about the llvm-commits mailing list