Do this simplification once for all associative binops. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- simplify.c | 5 +++++ validation/optim/reassoc-op-op1.c | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index 3935552bd6fa..b14f88405861 100644 --- a/simplify.c +++ b/simplify.c @@ -1295,6 +1295,11 @@ static int simplify_associative_binop(struct instruction *insn) return 0; if (!simple_pseudo(def->src2)) return 0; + if (constant(def->src2) && constant(insn->src2)) { + // (x # C) # K --> x # eval(C # K) + insn->src2 = eval_op(insn->opcode, insn->size, insn->src2, def->src2); + return replace_pseudo(insn, &insn->src1, def->src1); + } if (multi_users(def->target)) return 0; switch_pseudo(def, &def->src1, insn, &insn->src2); diff --git a/validation/optim/reassoc-op-op1.c b/validation/optim/reassoc-op-op1.c index aa7092ff57a0..3d050c142249 100644 --- a/validation/optim/reassoc-op-op1.c +++ b/validation/optim/reassoc-op-op1.c @@ -8,7 +8,6 @@ int foo(int x, int *ptr) /* * check-name: reassoc-op-op1 * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-output-ignore * check-output-pattern(1): add\\. -- 2.28.0