[PATCH] D20327: [InstCombine] transform multiplication overflow check written as a > (UINT_MAX /u b) to umul.with.overflow

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Tue May 17 10:59:52 PDT 2016


majnemer added a comment.

@sanjoy, you dealt with this sort of canonicalization before.  What are your thoughts?  Would we want this is InstCombine or CGP?  `umul_with_overflow` may be more canonical because it can be speculated...


================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:3253-3255
@@ -3252,1 +3252,5 @@
 
+  // a > (UINT_MAX /u b) is a portable way to check if a * b overflows --
+  // replace it with a umul_with_overflow
+  {
+    ConstantInt *CI;
----------------
This might not be a canonical transform if the division has multiple users.


http://reviews.llvm.org/D20327





More information about the llvm-commits mailing list