[PATCH] D35594: [GISel]: ConstantFold operations when building MIR

Aditya Nandakumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 19 10:34:58 PDT 2017


aditya_nandakumar added a comment.

This is helpful in cases where you try to build a generic operation on a constant.
For e.g.,
vreg1(s16) = G_CONSTANT 0
Builder.buildZExt(s32, vreg1) would result in
vreg1(s16) = G_CONSTANT 0
vreg2(s16) = G_ZEXT vreg1

Instead - we can constant fold operations and instead generate
vreg2(s32) = G_CONSTANT i32 0

Similarly we can constant fold binary operations such as Add/sub/or/and/xor/mul.

We also can constant fold intrinsics FABS/FLOG... (constant) -> constant.


Repository:
  rL LLVM

https://reviews.llvm.org/D35594





More information about the llvm-commits mailing list