[PATCH] D59472: [InstCombine] Add tests for add nuw + uaddo

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 18 12:58:17 PDT 2019


nikic added inline comments.


================
Comment at: llvm/test/Transforms/InstCombine/uadd-with-overflow.ll:54
+
+define { <2 x i32>, <2 x i1> } @no_fold_splat_undef_constant(<2 x i32> %x) {
+; CHECK-LABEL: @no_fold_splat_undef_constant(
----------------
lebedev.ri wrote:
> dlrobertson wrote:
> > lebedev.ri wrote:
> > > You could also add variations with non-splat non-undef constants
> > I'm not sure I follow. Wouldn't a non-splat non-undef variation of this test be something like `simple_fold` on line 10?
> I meant something like
> ```
>   %a = add nuw <2 x i32> %x, <i32 12, i32 13> ; not splat, but still no overflow, but won't get folded
>   %b = tail call { <2 x i32>, <2 x i1> } @llvm.uadd.with.overflow.v2i32(<2 x i32> %a, <2 x i32> <i32 30, i32 30>)
> ```
> ```
>   %a = add nuw <2 x i32> %x, <i32 12, i32 4294967280> ; not splat, overflow
>   %b = tail call { <2 x i32>, <2 x i1> } @llvm.uadd.with.overflow.v2i32(<2 x i32> %a, <2 x i32> <i32 30, i32 255>)
> ```
> 
To clarify terminology: "Splat" here means that all elements of a vector constant are the same (or undef, in which case we may assume them to be the same). Non-splat is if the elements differ. For many optimizations only the splat case is supported, because it is handled by matchers like m_APInt(). Handling non-splat cases typically requires using ConstantExpr based operations (instead of much more convenient APInt ones), so mostly nobody bothers...


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59472/new/

https://reviews.llvm.org/D59472





More information about the llvm-commits mailing list