[PATCH] D84942: [ConstantFolding] fold abs intrinsic

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 30 09:11:09 PDT 2020


spatel marked an inline comment as done.
spatel added inline comments.


================
Comment at: llvm/lib/Analysis/ConstantFolding.cpp:2858
 
     // Use the regular scalar folding to simplify this column.
     Constant *Folded =
----------------
Vector types are handled by calling the scalar fold for each element.


================
Comment at: llvm/test/Analysis/ConstantFolding/abs.ll:46
-; CHECK-NEXT:    [[R:%.*]] = call <8 x i8> @llvm.abs.v8i8(<8 x i8> <i8 -127, i8 -126, i8 -42, i8 -1, i8 0, i8 1, i8 42, i8 127>, i1 true)
-; CHECK-NEXT:    ret <8 x i8> [[R]]
 ;
----------------
aqjune wrote:
> (a silly question) abs with a vector input is optimized here, but this patch is about non-vector integers; do you have any idea which part of ConstantFolding.cpp is responsible for this?
Not silly - I used the vector test to reduce the number of tests needed, and it's not obvious from just this patch how that works. :)
I put an inline comment at the place where vectors get expanded. So this test is sequentially calling into the scalar code 8 times (once for each element of the vector).


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

https://reviews.llvm.org/D84942



More information about the llvm-commits mailing list