Only vector tests are being affected here,
since subtraction by scalar constant is rewritten
as addition by negated constant.
No surprising test changes.
Differential D62257
[DAGCombiner][X86][AArch64] (x - C) + y -> (x + y) - C fold lebedev.ri on May 22 2019, 8:10 AM. Authored by
Details
Only vector tests are being affected here, No surprising test changes.
Diff Detail
Event TimelineComment Actions Its rather annoying that the DAGCombiner::visitSUB limits the (sub x, c) -> (add x, -c) fold to non-vectors Comment Actions I suppose i could take a look at that, but i'd like to cram out the remaining patches for sink-addsub-of-const.ll. Comment Actions LGTM with one minor
Comment Actions And reduced test-suite/MultiSource/Benchmarks/TSVC/ControlFlow-dbl/tsc.c to ; ModuleID = 'bugpoint-reduced-simplified.bc' source_filename = "input.c" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" define dso_local <4 x i32> @b(<4 x i64> %arg) local_unnamed_addr #0 { %t0 = add <4 x i64> %arg, <i64 8, i64 8, i64 8, i64 8> %t1 = trunc <4 x i64> %t0 to <4 x i32> %t2 = add <4 x i32> %t1, <i32 1, i32 1, i32 1, i32 1> %t3 = and <4 x i32> %t2, <i32 3, i32 3, i32 3, i32 3> ret <4 x i32> %t3 } attributes #0 = { "use-soft-float"="false" } !llvm.ident = !{!0} !0 = !{!"clang version 9.0.0 (trunk 362014) (llvm/trunk 362022)"} Comment Actions Hmm yeah, i should have seen it coming. ; ((%arg0 + 8) - (-1)) %t0 = add %arg0, 8 ; 8 is constant, so hoist binop %t1 = sub %t0, -1 and will change that to ; ((%arg0 - (-1)) + 8) %t0 = sub %arg0, -1 ; -1 is constant, so hoist binop %t1 = add %t0, 8 and then the complementary fold will undo that, if we fail to constant-fold inbetween. |