Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
1,368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. From d2f45d7d310bd45fc0f160537e2109b8fd246072 Mon Sep 17 00:00:00 2001
  2. From: Tobias Droste <tdroste@gmx.de>
  3. Date: Mon, 18 Jul 2011 07:00:46 +0200
  4. Subject: [PATCH] r300/compiler: simplify code in peephole_add_presub_add
  5.  
  6. Signed-off-by: Tobias Droste <tdroste@gmx.de>
  7. ---
  8. .../drivers/dri/r300/compiler/radeon_optimize.c | 35 ++++++++++---------
  9. 1 files changed, 18 insertions(+), 17 deletions(-)
  10.  
  11. diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c b/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c
  12. index b242742..39dcb21 100644
  13. --- a/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c
  14. +++ b/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c
  15. @@ -561,28 +561,29 @@ static int peephole_add_presub_add(
  16. struct rc_instruction * inst_add)
  17. {
  18. unsigned dstmask = inst_add->U.I.DstReg.WriteMask;
  19. - struct rc_src_register * src1 = NULL;
  20. - unsigned int i;
  21. -
  22. - if (!is_presub_candidate(c, inst_add))
  23. - return 0;
  24. + unsigned src0_neg = inst_add->U.I.SrcReg[0].Negate & dstmask;
  25. + unsigned src1_neg = inst_add->U.I.SrcReg[1].Negate & dstmask;
  26.  
  27. if (inst_add->U.I.SrcReg[0].Swizzle != inst_add->U.I.SrcReg[1].Swizzle)
  28. return 0;
  29.  
  30. - /* XXX This isn't fully implemented, is it? */
  31. - /* src0 and src1 can't have absolute values only one can be negative and they must be all negative or all positive. */
  32. - for (i = 0; i < 2; i++) {
  33. - if (inst_add->U.I.SrcReg[i].Abs)
  34. - return 0;
  35. + /* src0 and src1 can't have absolute values */
  36. + if (inst_add->U.I.SrcReg[0].Abs || inst_add->U.I.SrcReg[1].Abs)
  37. + return 0;
  38.  
  39. - /* XXX This looks weird, but it's basically what was here before this commit (see git blame): */
  40. - if ((inst_add->U.I.SrcReg[i].Negate & dstmask) != dstmask && !src1) {
  41. - src1 = &inst_add->U.I.SrcReg[i];
  42. - }
  43. - }
  44. + /* presub_replace_add() assumes only one is negative */
  45. + if (inst_add->U.I.SrcReg[0].Negate && inst_add->U.I.SrcReg[1].Negate)
  46. + return 0;
  47. +
  48. + /* if src0 is negative, at least all bits of dstmask have to be set */
  49. + if (inst_add->U.I.SrcReg[0].Negate && src0_neg != dstmask)
  50. + return 0;
  51.  
  52. - if (!src1)
  53. + /* if src1 is negative, at least all bits of dstmask have to be set */
  54. + if (inst_add->U.I.SrcReg[1].Negate && src1_neg != dstmask)
  55. + return 0;
  56. +
  57. + if (!is_presub_candidate(c, inst_add))
  58. return 0;
  59.  
  60. if (presub_helper(c, inst_add, RC_PRESUB_ADD, presub_replace_add)) {
  61. @@ -615,7 +616,7 @@ static void presub_replace_inv(
  62. * of the add instruction must have the constatnt 1 swizzle. This function
  63. * does not check const registers to see if their value is 1.0, so it should
  64. * be called after the constant_folding optimization.
  65. - * @return
  66. + * @return
  67. * 0 if the ADD instruction is still part of the program.
  68. * 1 if the ADD instruction is no longer part of the program.
  69. */
  70. --
  71. 1.7.3.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement